i'm investigating kotlin example:
class html { fun body() { ... } } fun html(init: html.() -> unit): html { val html = html() // create receiver object html.init() // pass receiver object lambda return html } html { // lambda receiver begins here body() // calling method on receiver object }
i'm wonder how write code in scala? how declare in scala function type receiver?
there no equivalent in scala. you'd use function takes html
argument (possibly implicit argument, isn't reflected in type , unlikely in case).
Comments
Post a Comment