Numbers and Expressions in Ruby
Expressions:
When programming, an expression is a combination of data (such as numbers or strings of text), operators (such as + or -), and variables that, when understood by the computer, result in an answer of some form.
Example:
5 1 + 2 "a" + "b" + "c" 100 - 5 * (2 - 1) x + y
Variables:
Variables are placeholders or references to objects, including numbers, text, or any types of objects you’ve chosen to create.
Example:
x = 10 puts x 10
Here you assign the numeric value of 10 to a variable called x. Be aware that you always need to initialize variables (that is, assign a value to them) before using them, otherwise you will end up with an error. You can name variables however you like, with only a few limitations. Variable names must be a single unit (no spaces!); must start with either a letter or an underscore; must contain only letters, numbers, orunderscores; and are case sensitive.