Core concept

class Person(name: String)
object Person {
  def apply(n: String) = new Person(n)  // Person("Ada")
}
Advertisement

How it works

Case classes auto-generate companion.

Advertisement

Trade-offs + gotchas

Factories, statics, type class instances.