in ktor-server-html-builder-jvm, there’s an intere...
# ktor
a
in ktor-server-html-builder-jvm, there’s an interesting Kotlin detail that I’m wondering if anyone here knows more about:
respondHtml(status) { with(template) { apply() } }
is used as just doing
template.apply()
triggers the built in scope function
apply
. What is it about the use of
with
that makes Kotlin invoke the
apply
method on
HTML<T>
rather than the scope function? Is it something about member functions taking presedence in the parser/compiler when it’s called without an explicit receiver, or something like that? If I try and change it to
with(resp.body) { this.apply() }
, i.e. explicitly using
this
inside
with
, it tries to call the scope function again.