From: Markus Date: 2005-05-24T05:04:26+09:00 Subject: Array.=== Bug, Rails Bug, or brain failure? I've got some rails code that is failing in a very strange way. It is quite repeatable in situ, but I have yet to formulate a simple explanation of when it fails. Consider this code: case x when Array print "Array\n" else print "Bogus\n" if x.is_a? Array end Should it ever print "Bogus\n"? I wouldn't think so, but when x is the Array returned by main_record.sub_records (where main_record is linked to sub_records by a "has_many :sub_record") it does. The class of x is "Array" and (obviously) "x.is_a? Array" but "Array === x" returns false. It works for hand made arrays, the Array returned by "SubRecord.find_all_by_main_record(main_record.id)"--which should be identical. I've only found one place in the whole codebase (in activerecord) where === is redefined, and then only for active records themselves, not for the class, and certainly not for Class. In any case, it "redefines" it as "other.is_a?(self)", which is what I'd expect class to do. Adding: class Array def self.===(other) other.is_a? self end end right above the code in question fixes it. Has anyone else seen this? Did the semantics change when I wasn't looking? Or is there a bug somewhere? Or am I missing something subtly obvious? --MarkusQ