Skip to content

Define attributes inside object bodies

Yorick Peterse requested to merge define-attributes-in-objects into master

Instead of defining attributes inside the "init" method of an object, they now have to be defined in the object's body. This means that instead of this:

object Person {
  def init(name: String) {
    let @name = name
  }
}

You now write the following:

object Person {
  @name: String

  def init(name: String) {
    @name = name
  }
}

This makes it easier for both developer and compiler to determine which attributes an object has. This in turn can allow the compiler to (in the future) require that all defined attributes are initialised in the "init" method.

Merge request reports