I came across this strange syntax I have never seen before:
if self < Example::Class::Name
# do something
else
# do something else
end
What does this check?
It checks if self
is a subclass of Example::Class::Name
Check out the Module docs :)
This is checking if Example::Class::Name
is the superclass of self
by this sort of declaration:
class DemonstrationClass < Example::Class::Name
#de body of sub-class
def cascade *parameters
#de ...do work
super #de passes all parameters to the same method name of the super-class.
#de this even works on an initialize method declaration!
end
end
Instances of DemonstrationClass
are sub-classes of the Example::Class::Name
super class.
Sub-classes have the special feature of being able do things like what I showed in the cascade
method, and many more things.
Related questions with more sample code, and examples of associated concepts involved: