Today I came across the strange ruby syntax in the Rational class:
Rational(a,b)
(Notice the absence of the .new()
portion comp
The method Rational() is actually an instance method defined outside of the class Rational. It therefore becomes an instance method of whatever object loads the library 'rational' (normally main:Object) in the same way that 'puts' does, for example.
By convention this method is normally a constructor for the class of the same name.