#currying #functions #scala
Curried functions are defined with multiple parameter lists, as follows:
def strcat(s1: String)(s2: String) = s1 + s2
Alternatively, you can also use the following syntax to define a curried function:
def strcat(s1: String) = (s2: String) => s1 + s2
If you want to change selection, open document below and click on "Move attachment"
Scala Currying Functionsesume WritingComputer GlossaryWho is Who
Scala Currying Functions
Advertisements
Previous Page
Next Page
Currying transforms a function that takes multiple parameters into a chain of functions, each taking a single parameter. <span>Curried functions are defined with multiple parameter lists, as follows:
def strcat(s1: String)(s2: String) = s1 + s2
Alternatively, you can also use the following syntax to define a curried function:
def strcat(s1: String) = (s2: String) => s1 + s2
Following is the syntax to call a curried function:
strcat("foo")("bar")
You can define more than two parameters on a curried function based on your requirement. Let Summary
status | not read | | reprioritisations | |
---|
last reprioritisation on | | | suggested re-reading day | |
---|
started reading on | | | finished reading on | |
---|
Details