Ruby - Variables and Constants

This article will focus on variables and constants in Ruby.


Variables

Variables are used as a location to store a value. Variables are assigned using equal (=) sign.
Eg: x=5





Constants

Variables which starts with a capital letter is a constant where it's value cannot be changed.
Eg: MyNum = 20









Below output will be given when assigning a value to a constant variable.







Try out the code to get a more clear idea.

Comments

Popular posts from this blog

Working with Buttons in Android Studio

Java Part 2 :How to Install Java

Ruby - Dynamic, Open source programming language