Scala - Function


def functionName ([list of parameters]) : [return type]


High Order

Higher order functions are functions that take a function as a parameter or return functions.


  • Call by value: evaluates the function arguments before calling the function
  • Call by name: evaluates the function first, and then evaluates the arguments if needed
def square(x: Double)    // call by value
def square(x: => Double) // call by name
def myFct(bindings: Int*) = { ... } // bindings is a sequence of int, containing a varying # of arguments

Powered by ComboStrap