In the previous lesson, you were introduced to methods. Operators are simply methods called using the operator notation we discussed in the previous lesson.
Operators usually follow an infix notation. The infix notation is where the operator is situated between two operands. Operands are the data objects that the operator is performing an operation on.
After the operator has performed its specific operation, the output is the result of the operation.
What does this remind you of? A method. Where the operator is our function/method and the operand before the operator is the object the method acts upon. While the operand after the operator is the argument passed to the method.
In Scala operators are not special language syntax; any method can be an operator. What makes a method an operator is how you use it. When we wrote string1.indexOf('W') in the previous lesson, indexOf was not an operator. But when we wrote string1 indexOf 'W', indexOf was an operator, because we’re using it in operator notation.
In the previous lesson, we used the infix notation to call a method. In this lesson, let’s try to use an operator using the ordinary method call.
Note: The infix notation is a much simpler syntax and is the conventional way of using operators.