Convert string to integer with error : Convert to String « Number « Ruby






Convert string to integer with error


"6".to_i(2)                       # => 0
"0".to_i(1)
# ArgumentError: illegal radix 1
40.to_s(37)
# ArgumentError: illegal radix 37

 








Related examples in the same category

1.Integer passed into a string with interpolation
2.Substituting Variables Into Strings
3.constant value interpolation
4.String interpolation with method call
5.String interpolation with calculation
6.Convert float to string
7.Convert integer to string by parameter