Most languages use left-to-right associativity when evaluating mathematical expressions, but for those that don’t(C++), it’s left to the compiler to decide.

Short Circuiting

On a expression branch (i.e if (expression1 && expression2 && ..), if expression1 is evaluated to be false, then the rest expressions won’t be evaluate at all.

Similarly, for or conjunctions, if the first expression is true, then the rest of expressions won’t be evaluated.

In other words, the expressions will be evaluated until they meet the first one that satisfy the condition. After that, all of the rest will be ignored.

This optimization is called short-circuiting.

Iteration

3 major forms

Both collection-controlled (and often) counter-controlled loops replies on iterators

Iterable Objects

An iterable object is an object that holds, has access to, or can generate a sequence of values. An iterable object can be iterated over (using an iterator) to obtain its values.

Iterator

An iterator is an object that enables enumeration of an iterable object’s values. An iterator provides a way to access the values of an iterable object without exposing the iterable object’s underlying implementation

Iterators used with containers and external sources are typically distinct objects from the sequence they refer to. (i.e. so that multiple iterators could exists for the same object)

Generally, iterators implements the following method to work

For container and External Sources

For abstract sequences

And there are two primary approaches for creating iterators