convert a string to an integer, use to_i : Convert Number « String « Ruby






convert a string to an integer, use to_i


"100".class # => String
"100".to_i # => 100
"100".to_i.class # => Fixnum

 








Related examples in the same category

1.To convert a string into a float, use the to_f method
2.String to number