I am writing a 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 stay the same, of course.
Of course, I could do this by explicitly creating a new object of the appropriate type each time, as it was done in this example , however, there are breaks in the face of inheritance, since calling the methods in the instance of the subclass instead returns an instance of the superclass.
FWIW, I come from the land of OCaml, which has special syntax for supporting functional objects. For example, see here
So, does Scala have an equivalent for {< x = y >}in OCaml?
source
share