https://kotlinlang.org logo
s

simon.vergauwen

08/16/2021, 6:41 PM
Hey everyone 👋 Has there ever been any discussion to allow for passing regular lambdas where lambdas with receivers are expected? Effectively, ignoring the receiver of the lambda since it’s unused. See snippet below for example. This would be similar to the current functionality that allows for regular lambdas
() -> A
where
suspend () -> A
is expected.
e

ephemient

08/16/2021, 7:17 PM
Kotlin currently allows for passing
(T) -> R
where a
T.() -> R
is expected and vice versa. this sounds equivalent passing a
() -> R
where a
(T) -> R
is expected, which is not currently allowed either
if it were allowed then
Copy code
"🌍".let(::println)
which is currently unambiguous would have to consider both
println(Any?)
and
println()
s

simon.vergauwen

08/16/2021, 7:32 PM
Makes sense. A bit annoying since overloading to allow both lambdas is ambiguous