https://kotlinlang.org logo
Title
j

Justin Tullgren

08/26/2021, 1:45 PM
Hi, is it possible to have a lambda with receiver for
fun interface
types when creating them using the lambda syntax? I can't seem to make it work without actually making a concrete class.
y

Youssef Shoaib [MOD]

08/26/2021, 1:56 PM
That's because you're creating the FizzBuzz instance there, and so it won't work. The solution is probably to just remove the
FizzBuzz
receiver
j

Justin Tullgren

08/26/2021, 2:28 PM
@Youssef Shoaib [MOD] Yes that works. Is there anyway to keep the scope though? Removing the receiver makes the function globally available which i was hoping to avoid. Thanks for answering though!
i think i found a solution. thanks!