9. If else

9.9 String vs Integer

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

Execute the above code and you will see that number 12 is not the same as string 12.

Converting String to Integer

How do I 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.