Possible Duplicate:
=== vs. == in Ruby
Fixnum == 2.class
#=> true
Fixnum === 2.class
#=> false
why === doesn’t work? and how can I know the method .=== belong to(right now I guess it invoke the Object#==, or Object#===), but how can I make sure of that?
Duplicates:
Case equality. See the documentation for Object#===. This method is usually overridden in subclasses of
Object. For example, Module#===:Regexp#=== is another one, in which case it’s a synonym of
=~:An example in IRB:
Remember, the first one returns false because you’re doing
===onStringwhich isn’t the same thing. In the second example we’re doing===onRegexpAnd finally, Range is quite a good one it calls
include?on the Range object and passes your value in:For a list of these, check out RubyDoc.info core documentation and search for
===in the methods area in the left side frame