-
-
Save nimish-mehta/b6b7d49711eafbb3fcb7f50fd5c79849 to your computer and use it in GitHub Desktop.
Matching Fixnum with integer in different ruby versions
This file contains 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 ruby -v | |
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin16.0] | |
➜ ruby ruby test_fixnum_2.rb | |
Found a number | |
Fixnum | |
1 |
This file contains 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 ruby -v | |
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin15] | |
➜ ruby ruby test_fixnum_2.rb | |
Found an integer | |
Fixnum | |
1 |
This file contains 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 ruby -v | |
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin15] | |
➜ ruby ruby test_fixnum_2.rb | |
Found a number | |
Integer | |
1 |
This file contains 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
arg = 1 | |
case arg | |
when Integer then | |
puts "Found a number" | |
puts arg.class | |
puts arg.to_i | |
else | |
puts "Could not match" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment