https://kotlinlang.org logo
#announcements
Title
# announcements
e

enleur

06/28/2017, 6:39 PM
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

ilya.gorbunov

06/28/2017, 9:37 PM
@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

enleur

06/28/2017, 10:10 PM
Thank you
2 Views