Package objects

// in file gardening/fruits/Fruit.scala
package gardening.fruits

case class Fruit(name: String, color: String)
object Apple extends Fruit("Apple", "green")
object Plum extends Fruit("Plum", "blue")
object Banana extends Fruit("Banana", "yellow")
package object fruits extends FruitAliases with FruitHelpers {
  // helpers and variables follows here

Scala provides package objects as a convenient container shared across an entire package. Package objects can contain arbitrary definitions, not just variable and method definitions. .

Package objects → are a → Objects.

Package objects — Structure map

Clickable & Draggable!

Package objects — Related pages: