So as I understand it, the ===
operator tests to see if the RHS object is a member of the LHS object. That makes sense. But how does this work in Ruby? I\'m loo
It's defined on Module, which Class is a subclass of, which Integer is an instance of.
In other words, when you run Integer === 3
, you're calling '===' (with the parameter 3) on the object referred to to by the constant Integer, which is an instance of the class named Class. Since Class is a subclass of Module and doesn't define its own ===
, you get the implementation of === defined on Module.
See the API docs for Module for more information.