Differences
This is not completely interchangeable, since the "lambdas extension", technically called lambdas with the receiver , can be called on the receiver, which is not possible with regular lambdas:
predicateWithReceiver(2)
2.predicateWithReceiver()
regularPredicate(2)
2.regularPredicate
Lambdas , - ( ). , , .. .
. , 2.regularPredicate - ( Java):
Function1 predicateWithReceiver = ...;
predicateWithReceiver.invoke(2);
, .
, filter, . , ( Java):
public static final void filter(@NotNull List list, @NotNull Function1 predicate) {
if ((Boolean)predicate.invoke(number)) {
System.out.println(number);
}
}
}
Function1. , lambdas reiceiver . , predicate Kotlin.