if I need a function inside another function I can...
# announcements
e
if I need a function inside another function I can do it in several ways:
Copy code
val isCool = fun(a: Int) = a > 0
val isCool = { a: Int -> a > 0 }
fun isCool(a: Int) = a > 0
are there any differences or pitfalls?
i
@enleur The difference between first and second form is that unqualified
return
is allowed inside anonymous
fun
but not inside lambda. The third one declares a function
isCool
, rather than a variable of functional type.
👍 1
e
Thank you