Functional and Rational Object in Scala
Rational Object:
A good place to start designing class Rational is to consider how client
programmers will create a new Rational object. Given we’ve decided to make Rational objects immutable, we’ll require that clients provide all data needed by an instance when they construct the instance. It has the following syntax:
class Rational(n: Int, d: Int)
Here, [java]this.numer[/java] refers to the numerator of the object on which less than was invoked. You can also leave off this prefix and write just [java]numer;[/java] the two notations are equivalent.