Scala notes: basic functions

A few notes for myself so I don’t forget:

A function like:

f(x) = x * x

is declared in Scala like:

def square(x : Int) = x * x

… which is a function called square, which takes a value x which is of type Int, and calculates the square of x.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.