Classes and objects In Scala, a class is a blueprint for objects. Once you define a class, you can create objects from the class blueprint with the keyword new. Through the object you can use all functionalities of the defined class.
An object is a named instance with members such as fields and methods. It is a class that has exactly one instance. There are three uses of objects.
Function Syntax Scala is a functional programming language, which means that functions are first-class citizens and you can pass them around as parameters or values.
def add(x: Int, y: Int): Int = { return x + y; } println(add(21, 19)); // Other variants def multiply(x: Int, y: Int): Int = x * y // simplified version def divide(x: Int, y: Int) = x / y // can ignore the output type if it's obvious def substract(x: Int = 10, y: Int = 2) = x - y // set default values You can define the function names as operator, e.