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 thataandbare parameters of the methodadd. 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 keywordreturnto 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