This is a method of lazily initializing an @song instance @song .
If @song already set (some plausible value, i.e. not nil or false ), then the expression just evaluates that value.
If, however, @song is not already set for that value, then it creates a new instance of the TwelveDaysSong class and assigns it to @song . Then, as before, the expression evaluates the @song value, but this value is now a reference to the newly created TwelveDaysSong object.
Using :: in a class name means that it is an absolute top-level class; it will use the top-level class even if there is a TwelveDaysSong class defined in any current module.
source share