Skip to content

Instantly share code, notes, and snippets.

View bkahlert's full-sized avatar
😷

Björn Kahlert bkahlert

😷
View GitHub Profile
@bkahlert
bkahlert / MultiReceiver.kt
Last active February 25, 2021 23:06 — forked from Takhion/MultiReceiver.kt
Multiple receivers in Kotlin
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() {