Philip Dukhov
11/03/2021, 12:59 PMval onAction: () -> Unit = { ... }
) as blocks. Is this naming clear to android developers? The word lambda in my head does not sound very nice in this context.Rahul Rawat
11/03/2021, 1:09 PMephemient
11/03/2021, 1:17 PMfun
syntax.Vampire
11/03/2021, 1:21 PM{ .... }
part is the lambda.
val onAction
is the declaration of a read-only variable, field or property.
() -> Unit
is a function type that is the type of the variable.arekolek
11/03/2021, 1:21 PMval onAction: () -> Unit = { ... }
by the word _block_"ephemient
11/03/2021, 1:21 PMVampire
11/03/2021, 1:21 PMephemient
11/03/2021, 1:25 PM{ .. }
syntax forms a lambda expression, which may translate to an instance of a function or SAM type, or get inlined into no instance at all, depending on context. the word "block", if used, I'd expect to mean some scoped unit of code (as in Java)Philip Dukhov
11/03/2021, 1:31 PMAdam Powell
11/03/2021, 1:31 PMblock: () -> Unit
in kotlin stdlib functions as well as Android-centric libraries, especially in the case of inline functions where the parameter is called in place before the function returnsAdam Powell
11/03/2021, 1:32 PMVampire
11/03/2021, 1:33 PMAdam Powell
11/03/2021, 1:53 PM{ doSomethingWith(someVal) }
is a lambda expression, () -> Unit
is a function type. Some people use the word lambda when referring to function types even when that's not fully correct, etc.Adam Powell
11/03/2021, 1:54 PM