Error in rounding off values using .round in Ruby
Posted
by Shreyas Satish
on Stack Overflow
See other posts from Stack Overflow
or by Shreyas Satish
Published on 2010-05-01T04:41:34Z
Indexed on
2010/05/01
4:47 UTC
Read the original article
Hit count: 354
The following piece of code works perfectly in script/console but returns the following error when i compile the same in a ruby script.: :in `round': wrong number of arguments (1 for 0) (ArgumentError)
tf={"ph"=>{0=>1.33333333333333, 1=>1.5}, "fee"=>{0=>1.66666666666667}, "test"=>{0=>1.16666666666667, 1=>1.25}, "what"=>{0=>2.0, 1=>2.0}, "for"=>{0=>1.5}, "is"=>{0=>1.83333333333333, 1=>1.75}}
tf.each{|k,v| v.each{|k1,v1| tf[k][k1]=(v1.round(5))}}
Any Ideas ? Cheers !
© Stack Overflow or respective owner