Skip to content
Search

Scala:ByNameParameters

lastmod 2020-09-13created 2020-09-132 edits

A by-name parameter is a technique for passing a function as a parameter and applying lazy evaluation to that function.

Put more simply, you can use it when you want to delay the evaluation of a parameter. This is similar to replacing the by-name parameters with the passed expressions.

Usage

To apply it, add => in front of the type.

def calculate(input: => Int) = input * 37

See also

Favorite site

author Zer0 sitemap