Sol*_*Sol 6 lambda scala kotlin
我正在调查这个Kotlin的例子:
class HTML {
    fun body() { ... }
}
fun html(init: HTML.() -> Unit): HTML {
  val html = HTML()  // create the receiver object
  html.init()        // pass the receiver object to the lambda
  return html
}
html {       // lambda with receiver begins here
    body()   // calling a method on the receiver object
}
我想知道如何在scala中编写这段代码?如何用接收器声明scala函数类型?
| 归档时间: | 
 | 
| 查看次数: | 378 次 | 
| 最近记录: |