To convert a string into a float, use the to_f method : Convert Number « String « Ruby






To convert a string into a float, use the to_f method


"200".class # => String
"200".to_f # => 200.0
"200".to_f.class # => Float

 








Related examples in the same category

1.convert a string to an integer, use to_i
2.String to number