在JRuby(1.6.x)中,如何将浮点值舍入到小数点后2位?
number = 1.1164
number.round(2)
# The above shows the following error
# wrong number of arguments (1 for 0)
在JRuby(1.6.x)中,如何将浮点值舍入到小数点后2位?
number = 1.1164
number.round(2)
# The above shows the following error
# wrong number of arguments (1 for 0)
Float#round可以接受Ruby 1.9中的参数,而不是Ruby 1.8中的参数.JRuby的默认值为1.8,但它可以达到running in 1.9 mode.