Created
May 8, 2009 03:22
-
-
Save snusnu/108594 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):001:0> class Foo; end | |
=> nil | |
irb(main):002:0> class Bar; end | |
=> nil | |
irb(main):003:0> f = Foo.new | |
=> # | |
irb(main):004:0> case f.class | |
irb(main):005:1> when Foo then puts “f.class = Foo” | |
irb(main):006:1> when Bar then puts “f.class = Bar” | |
irb(main):007:1> else | |
irb(main):008:1* puts “no match found” | |
irb(main):009:1> end | |
no match found | |
=> nil | |
irb(main):010:0> case f.class.name | |
irb(main):011:1> when “Foo” then puts “f.class.name = ‘Foo’” | |
irb(main):012:1> when “Bar” then puts “f.class.name = ‘Bar’” | |
irb(main):013:1> else | |
irb(main):014:1* puts “no match found” | |
irb(main):015:1> end | |
f.class.name = ‘Foo’ | |
=> nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment