Ruby program to convert the string into a floating-point number

bookmark

str = "10.5";
result = str.to_f();  

print "Result: ",result;

 


Output:

Result: 10.5