OneBite.Dev - Coding blog in a bite size

declare an integer in Ruby

Code snippet on how to declare an integer in Ruby

number = 5

This code declares a variable called ‘number’ and sets it equal to the number 5. Variables are used to store information so that it can be used in a computer program. The variable ‘number’ is declared as an integer, which is a data type that contains whole numbers. This means it can’t hold any decimal values such as 10.3. The variable has been set to the value 5, and this value can be used anywhere in the code that the variable has been declared. For example, if this code was written in a loop, the value of ‘number’ will be 5 each time the loop is executed.

ruby