How do you override the ruby case equality operator? (===)
问题 I have a class that I want to compare to both strings and symbols in a case statement, so I thought that I just override the ===() method for my class and all would be gold. However my ===() method never gets called during the case statement. Any ideas? Here is some example code, and what happens in a irb session: class A def initialize(x) @x=x #note this isn't even required for this example end def ===(other) puts "in ===" return true end end irb(main):010:0> a=A.new("hi") => # irb(main):011