I'm writing class in Scala and want to write some update methods that will return a modified version of the original object. I want the class to continue to be immutable of course.
Of course I could do it by explicitly creating a new object of the appropriate type each time, as is done in this example, however that breaks in the face of inheritance since calling the methods on an instance of the subclass would instead return an instance of the superclass.
FWIW, I come from the land of OCaml which has special syntax to support functional objects. For an example, see here
So, does Scala have an equivalent for {< x = y >}
in OCaml?