Purpose of this chapter.
We will learn about the expressions which is the elements that make up the statement.
An element of the program that returns a value.
An expression is an element that returns an instance on the code.
The minimum expression in Rice is the following two.
These are expressions that return an instances by themselves.
A new expression will be generated by combining operators with the instances returned by the expression. You can repeat such process as many times as necessary.
As a result, an instance will be returned. This is the result of the whole expression.
int i = 5; //#1
int j = 5; //#1
int k = i + j + 10; //#2
#1 defines a variable by the instance returned by the expression on the right side. As a result, this variable refers to an instance of the int class. Its value is 5.
The i + j of #2 applies the addition operator to the instances referred to by i and j. As a result, new instance of the int class are returned. Its value is 10.
The addition operator applies to the new instance and the instance returned by the literal. And, new instance of the int class is returned again. Its value is 20. The variable k is defined in this instance.
Let us explain about references, literals, and operators in the following chapters.