Type Casting (Type Conversion)

Learn to convert one data type into another in Ruby.

Casting data types example#

Let’s write a program to calculate our age in months. We’ll ask for the age in years, and our program will multiply this number by 12. Based on our knowledge from previous chapters, we should have something like this:

Get hands-on with 1200+ tech skills courses.