Variables and Assignment
To store a number or a string in your computer's memory for use later in your program, you need to give the number or string a name. Programmers often refer to this process as assignment and they call the names variables. A variable springs into existence as soon as the interpreter sees an assignment to that variable.
Local variables have the quality of barewords; they must start with either a lowercase letter or the underscore character (_), and they must consist entirely of letters, numbers, and underscores. Remember, local variable references look just like method invocation expressions.
Keywords can't be used as variable names. def is a keyword; the only thing you can use it for is to start a method definition. if is also a keyword; lots of Ruby code involves conditional clauses that start with if, so it would be too confusing to also allow the use of if as a variable name.
Method calls can be barewords, such as start_here. puts is a method call; so is print. When Ruby sees a bareword, it interprets it as one of three things: a local variable, a keyword, or a method call. (a) If there's an equal sign (=) to the right of the bareword, it's a local variable undergoing an assignment. (b) If the bareword is a keyword, it's a keyword (Ruby has an internal list of these and recognizes them). (c) Otherwise, the bareword is assumed to be a method call. If no method by that name exists, Ruby raises a NameError.
The p004stringusage.rb shows us some more usage with strings.
In the example:
x = "100".to_i
the dot means that the message "to_i" is being sent to the string "100", or that the method to_i is being called on the string "100". The string "100" is called the receiver of the message. Thus, when you see a dot in what would otherwise be an inexplicable position, you should interpret it as a message (on the right) being sent to an object (on the left).
Summary
I have listed down all the important points you need to remember after you have completed the following topics: Introduction, Installation, First Ruby program, Features of Ruby, Numbers in Ruby, String fundamentals and Variables and Assignment.