Created
May 12, 2012 13:57
-
-
Save wnuqui/2666644 to your computer and use it in GitHub Desktop.
safe conversions instead of to_x
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
i = "1i" | |
i.to_i # => 1 | |
Integer(i) # => ArgumentError: invalid value for Integer(): "1i" | |
f = "1.2f" | |
f.to_f # => 1.2 | |
Float(f) # => ArgumentError: invalid value for Float(): "1.2f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment