Objects

object IdFactory {
  private var counter = 0
  def create(): Int = {
    counter += 1
    counter
  }
}
val newId: Int = IdFactory.create()
println(newId) // 1
val newerId: Int = IdFactory.create()
println(newerId) // 2

Objects are single instances of their own definitions.

Objects — Structure map

Clickable & Draggable!

Objects — Related pages: