Scala Immutable Object: Difference between revisions

From GM-RKB
Jump to navigation Jump to search
m (Text replacement - "---- __NOTOC__" to "---- __NOTOC__")
m (Text replacement - ". ----" to ". ----")
 
Line 1: Line 1:
A [[Scala Immutable Object]] is a [[Immutable Object]] that is a [[Scala object]].
A [[Scala Immutable Object]] is a [[Immutable Object]] that is a [[Scala object]].
* <B>See:</B> [[Java Immutable Object]], [[Scala Mutable Object]].
* <B>See:</B> [[Java Immutable Object]], [[Scala Mutable Object]].
----
----
----
----

Latest revision as of 20:42, 23 September 2021

A Scala Immutable Object is a Immutable Object that is a Scala object.



References

2013

  • (2013, Melli)
trait Versioned {
  def version : Int
  def nextVersion = version + 1 
}

case class Customer(name: String, version : Int = 0) extends Versioned {
  def withName(newName: String) = copy(name = newName, version = nextVersion)
}