Phu  | 2 minutes | Tags:  scala

Call-by-value - Call-by-name

Tail recursion:

For

for expression <=> flatMap, withFilter, and map

Methods

To define a prefix operator, write: def unary_- : <type> = {}, the space before : is required to not make the colon a part of the identifier. Only 4 operators can be used: + - ! ~

To refer to a method foo from a function foo inside another method, write like this

trait Bar {
  self =>

  def foo: T
  
  def waz: U = {
    def foo = self.foo // or like Java: Bar.this.foo
  }
}

Only the primary constructor of a class can call the superclass constructor.
Every auxiliary constructor must invoke another constructor as its first action.

Traits further to the right take effect first: the method at the rightest is called first; if it calls super, it invokes the method in the trait to its left.