Learn Ruby
If Else
7.9
Lesson

String vs Integer

There is a difference between string 12 and number 12. They are not the same.

Converting String to Integer

How to convert string 12 to integer 12? Ruby has a method called to_i. It converts string into integer.

In the next example we will convert string 12 to integer 12 and then we will compare with 12 to see if to_i converts a string into an integer or not.