0
我觉得我错过了一些非常明显的东西。Ruby on Rails:无法将哈希值转换为浮点数
我有以下散列放置在变量“simple_lable”。调用它检查工作正常,但我似乎无法访问任何数值。 .to_i出来为0,.to_f出来为0.0和to_s出来空白
puts "**************************"
puts simple_label.inspect
puts simple_label["margin_top"].to_f
puts simple_label["margin_bottom"].to_f
puts simple_label["margin_right"].to_f
puts simple_label["margin_left"].to_f
puts simple_label["paper_size"]
puts "**************************"
结果
**************************
{"paper_size"=>"LETTER", "top_margin"=>36, "bottom_margin"=>36, "left_margin"=>15.822, "right_margin"=>15.822, "columns"=>3, "rows"=>10, "column_gutter"=>15, "row_gutter"=>0}
0.0
0.0
0.0
0.0
LETTER
**************************
所以价值是有的,但我似乎无法得到保持正确的。
任何想法?
非常感谢。
你是如此的正确(拍拍额头!)。我想有时它只是需要另一双眼睛,非常感谢:) –
@BjornForsberg没有问题。我一眼就看不到它。 – lurker