https://kotlinlang.org logo
#getting-started
Title
# getting-started
c

CLOVIS

03/25/2024, 9:38 PM
Trivia question: how many receivers can a single function have, without using context receivers? One is easy, it's just a regular top-level extension function. Two is a bit harder: it's an extension function declared in a class. Is it possible to do more? I thought about inner classes, but those have implicit access to their outer class, it's not really an additional receiver since it isn't sourced from the callsite.
a

Adam S

03/25/2024, 10:22 PM
Do local functions count?
Copy code
fun Cxt1.one() {
  fun Cxt2.two() {
    fun Cxt3.three() {
      fun Cxt4.four() {
        fun Cxt5.five() {
          println(p1)
          println(p2)
          println(p3)
          println(p4)
          println(p5)
        }
      }
    }
  }
}
playground
😄 3
👍 1