Damien O'Hara
07/16/2023, 7:06 AMval uppercased by Uppercased()
with ("two") {
println(uppercased) // "TWO"
}
with ("three") {
println(uppercased) // "THREE"
}
I tried experimenting with context receivers on delegate's getValue
but it only uses the context from the by Uppercased()
lineGleb Minaev
07/16/2023, 8:43 AMuppercased
like this:
context(String)
val Uppercased.value get() = this@String.uppercase()
...
with("two") {
println(uppercased.value)
}
Damien O'Hara
07/16/2023, 8:49 AMYoussef Shoaib [MOD]
07/16/2023, 10:36 AMprovideDelegate
Damien O'Hara
07/16/2023, 10:42 AMYoussef Shoaib [MOD]
07/16/2023, 10:44 AMasdf asdf
07/16/2023, 2:53 PMWout Werkman
07/17/2023, 1:53 PMDamien O'Hara
07/17/2023, 3:53 PMgetValue
itself so I can declare like val uppercased by ...
without the String.
at the declaration site. Still, pretty close to what I need!Youssef Shoaib [MOD]
07/17/2023, 3:55 PMPrefixedUpperCase
value is only provided at call site there, and so contexts should work the same way. I'll make an issue when I get the time, but anyone's free to make it.Wout Werkman
07/17/2023, 4:30 PMYoussef Shoaib [MOD]
07/17/2023, 4:38 PMsetValue
calls on certain special delegated variables. The way I "fixed" it was to track the child blocks that were being created, and delegate the method call to them, which is very inelegant.