Let’s say I have, as part of a DSL, the following ...
# announcements
j
Let’s say I have, as part of a DSL, the following class
Copy code
class ListScope {
    internal val items = mutableListOf<BulletedListItem>()

    operator fun String.unaryMinus() = items.add(BulletedListItem(this))
}
allowing me to use
Copy code
list {
    - "first item"
    - "second item"
}
Am I right to say that it’s impossible to do the same with an extension function of ListScope? I.e. something like
Copy code
class ListScope {
    internal val items = mutableListOf<BulletedListItem>()
}

operator fun ListScope.String.unaryMinus() = items.add(BulletedListItem(this))
r
Yeah, functions with multiple receivers are not supported at the moment. There is an open discussion issue around this feature here: https://youtrack.jetbrains.com/issue/KT-10468
👍 2