Ruby syntax looks like this:
2.add(3)
The thing on the left side of the (.), is called the object.
The thing on the right side of the (.), is called the method.
There are two parts within the method (refer to example above):
add is called the name of the method.
(3) is called the argument to the method.
The object, method, and argument make up an expression
An expression is evaluated and the method returns another object, which replaces the expression.
Ruby evaluates expression by searching for the first complete, self-contained expression.
In order to display the result of each expression we have to explicitly command it to print the lines that we want to see.
Top comments (0)