Skip to content

Instantly share code, notes, and snippets.

@mperham
Created February 10, 2014 19:43
Embed
What would you like to do?
Rubby numeric handling
> require 'bigdecimal'
=> true
> Float('foo')
ArgumentError: invalid value for Float(): "foo"
from (irb):2:in `Float'
from (irb):2
from /Users/mikep/.rubies/ruby-2.0.0-p353/bin/irb:12:in `<main>'
> Integer('foo')
ArgumentError: invalid value for Integer(): "foo"
from (irb):3:in `Integer'
from (irb):3
from /Users/mikep/.rubies/ruby-2.0.0-p353/bin/irb:12:in `<main>'
> BigDecimal('foo')
=> #<BigDecimal:7fccf7178fb0,'0.0',9(9)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment