Skip to content

Instantly share code, notes, and snippets.

Avatar
😷

Björn Kahlert bkahlert

😷
View GitHub Profile
@bkahlert
bkahlert / MultiReceiver.kt
Last active Feb 25, 2021 — forked from Takhion/MultiReceiver.kt
Multiple receivers in Kotlin
View MultiReceiver.kt
fun <A, B, C, R> multiReceiver(f: A.() -> B.() -> C.() -> R) = { a: A, b: B, c: C -> f(a)(b)(c) }
val sample1: (X, Y, Z) -> Int = multiReceiver { { { x + y + z } } }
val sample2: X.() -> Y.() -> Z.() -> Int = { { { x + y + z } } }
class X(val x: Int)
class Y(val y: Int)
class Z(val z: Int)
fun main() {