Scala - Function

Card Puncher Data Processing

Syntax

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

Signature

See Scala - Type

High Order

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

Evaluation

  • 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





Discover More
Card Puncher Data Processing
Scala - High Order Function (Function as parameter or return object)

Higher order functions are functions that take a function as a parameter or return functions. Functions in functional programming are higher order functions since following actions can be performed with...
Card Puncher Data Processing
Scala - Method

A function, which is defined as a member of some object, is called a method. See



Share this page:
Follow us:
Task Runner