How does `val that : Int -> Int = { three ->...
# getting-started
s
How does
val that : Int -> Int = { three -> three }
fit the definition
val lambdaName : Type = { argumentList -> codeBody }
? https://www.baeldung.com/kotlin-lambda-expressions
n
the type is
(Int -> Int)
it’s a higher order function that takes a
Int
as a parameter and returns an
Int
it’s defined as a function that returns the same value as its argument: the identity function
don’t be puzzled by
{three -> three}
it could have been written
{one -> one }
or
{it -> it }
and since
it
is the default parameter name
{it}
s
Parameter is
that
of type higher-order function
(Int -> Int)
and we have a function which takes one argument
three
and returns
three
. Is that correct?
n
yes
s
Thanks. This will take some time to imbibe and for me to be able to use them.
👍 1