OneBite.Dev - Coding blog in a bite size

declare a local variable in Ruby

Code snippet on how to declare a local variable in Ruby

  myVariable = 10

This code example declares a local variable in Ruby called “myVariable” and assigns it the value of 10. Local variables in Ruby are denoted by a lowercase letter or underscore followed by any combination of letters, numbers, and underscores. This type of variable is only accessible in the scope it is declared in. By assigning a value to the variable, we can later use this variable to refer to the value 10. For example, if we were to print out the value of the variable, we would get the number 10.

ruby