Typo in Builder-Koan solution?


#1

The solution 4c to the Builders how it works koan has the following code snippet:

tr (color = "yellow") { TR.(): Unit ->
      this.td {
          text("Product")
      }
}

Is that valid Kotlin code? At least when I paste it back into the Task.kt source, I get compilation errors.


#2

It’s the obsolete Kotlin syntax.
Thanks for noticing, I’ll remove the TR.(): Unit -> syntax from the question.
If you need to specify the receiver type explicitly, you can use the anonymous function instead https://kotlinlang.org/docs/reference/lambdas.html#function-literals-with-receiver.