DEV Community

Enrque\m/Talavera
Enrque\m/Talavera

Posted on

1

chapter 21,chapter22

Functions literals can be assigned to val fields to create function variables.
To be consistent with algebra and other FP resources, I refer to these fields are variables rather than values.
Examples of the val function syntax.
A function is an instance of a FunctionN trait, such as Function1, or Function2.
What various function type signatures look like in the REPL.
How to treat a function as a variable by putting it in a Map.
That, in general you can use a function variable just like any other variable.

A def mehtod is not a val (Part I)
A def mehtod is not a variable(Part II)
val =>creates an instance of the Function1 trait
def => create method

Convert def method to function.
def double(i:Int) = i*2

val doubleF = double _

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay