jbnizet
02/28/2020, 12:09 PMclass ListScope {
internal val items = mutableListOf<BulletedListItem>()
operator fun String.unaryMinus() = items.add(BulletedListItem(this))
}
allowing me to use
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
class ListScope {
internal val items = mutableListOf<BulletedListItem>()
}
operator fun ListScope.String.unaryMinus() = items.add(BulletedListItem(this))
robin
02/28/2020, 1:46 PM