Advertisement
whitequark

Case equality weirdness

Aug 7th, 2011
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.55 KB | None | 0 0
  1. ruby-1.9.2-p180 :004 > class A
  2. ruby-1.9.2-p180 :005?>   def ===(other)
  3. ruby-1.9.2-p180 :006?>     puts "A#===(#{other.inspect}) called"
  4. ruby-1.9.2-p180 :007?>     end
  5. ruby-1.9.2-p180 :008?>   end
  6.  => nil
  7. ruby-1.9.2-p180 :009 > class B
  8. ruby-1.9.2-p180 :010?>   def ===(other)
  9. ruby-1.9.2-p180 :011?>     puts "B#===(#{other.inspect}) called"
  10. ruby-1.9.2-p180 :012?>     end
  11. ruby-1.9.2-p180 :013?>   end
  12.  => nil
  13. ruby-1.9.2-p180 :014 > case A.new
  14. ruby-1.9.2-p180 :015?>   when B.new
  15. ruby-1.9.2-p180 :016?>   end
  16. B#===(#<A:0xa2e7930>) called
  17.  => nil
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement