When OO and FP meet: returning the same type
In the left corner, we have Functional Programming. FP says, “Classes shall be immutable!” In the right corner, we have Object-Oriented programming. It says, “Classes shall be extendable!” The battlefield: define a method on the abstract class such that, when you call it, you get the same concrete class back. In Scala.Fight! Here comes the …