Call a method on a single shared object.

Singleton Objects

SingletonObject.scala
object FeeRules {
  val fee = 2

  def addFee(amount: Int): Int = {
    amount + fee
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val amount = 
    val total = FeeRules.addFee(amount)

    println("amount=" + amount)
    println("total=" + total)
  }
}
object FeeRules {
  val fee = 2

  def addFee(amount: Int): Int = {
    amount + fee
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val amount = 
    val total = FeeRules.addFee(amount)

    println("amount=" + amount)
    println("total=" + total)
  }
}
object FeeRules {
  val fee = 2

  def addFee(amount: Int): Int = {
    amount + fee
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val amount = 
    val total = FeeRules.addFee(amount)

    println("amount=" + amount)
    println("total=" + total)
  }
}
singleton-object An object defines one shared instance. It is useful for constants and stateless helpers.