Scala Method with Arguments

In programming language, a method does some operations and return a result.

In most use cases, the method will take parameters to perform the operation.

You have learned that a and b are parameters of the method add. You can use them as normal values but only within the method. You can extend the context to several lines with {...}.

In some other programming language, like Java, you need the keyword return to make the method return a value but in Scala, the last line of the method is what is being returned automatically.

Reveal more information and clues
Load Exercise