Casting to a Float

suggest change
"123.50".to_f   #=> 123.5
Float("123.50") #=> 123.5

However, there is a difference when the string is not a valid Float:

"something".to_f   #=> 0.0
Float("something") # ArgumentError: invalid value for Float(): "something"

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents