Created
September 17, 2010 23:54
-
-
Save spheromak/585165 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
#!/bin/env ruby | |
foo = "someval" | |
puts "===" | |
puts foo.class === "String" | |
puts foo.class === String | |
puts "\n==" | |
puts foo.class == "String" | |
puts foo.class == String | |
puts "\neql?" | |
puts foo.class.eql? "String" | |
puts foo.class.eql? String | |
puts "\nCase" | |
case foo | |
when String | |
puts "STRING" | |
when "String" | |
puts "QUOTED STRING" | |
end | |
puts "\n Case class: #{foo.class}" | |
case foo.class | |
when String | |
puts "STRING" | |
when "String" | |
puts "QUOTED STRING" | |
end |
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
ruby foo.rb | |
=== | |
true | |
false | |
== | |
false | |
true | |
eql? | |
false | |
true | |
Case | |
STRING | |
Case class: String |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
why ?