Roshan Book

My Tech Notebook

Category Archives: ruby tutorial

Learning Ruby Part 12 Changing data type and Declaring constant

c=13 (here c has a integer value)

c.to_f – This changes c data type to float

This type of data changing is called Casting

Similarly for strings

num = 10
num.to_s => “10”

Declaring a constant

Start with capital letter. Like Variable=10

%d bloggers like this: