Saharath Kleips
01/30/2024, 8:40 PMwith
closer to the function call?
object X {
fun Unit.print(): String = "From X"
}
object Y {
fun Unit.print(): String = "From Y"
}
with(X) {
with(Y) {
Unit.print() // "From Y"
}
}
marlonlom
01/30/2024, 9:18 PMSaharath Kleips
01/30/2024, 9:54 PMSaharath Kleips
01/30/2024, 9:55 PMmarlonlom
01/30/2024, 10:40 PM.also(::println)
marlonlom
01/30/2024, 10:42 PMwith() { ... }
Saharath Kleips
01/30/2024, 10:47 PMSaharath Kleips
01/30/2024, 10:47 PMUnit.print()
function from X
rather than Y
? Or is the only way to disambiguate to change the ordering?marlonlom
01/30/2024, 11:13 PMKlitos Kyriacou
01/31/2024, 9:29 AMUnit.print()
to with(X) { Unit.print() }
. It doesn't matter that you already have an outer with
.Saharath Kleips
01/31/2024, 3:02 PMwith(y) {
with(x) { /** do something with x */ }
// do stuff with y
with(x) { /** do something with x */ }
// etc.
}
So it would have been convenient to just start my function like
fun doStuff() = with(x) {
with(y) {
...
}
}
Klitos Kyriacou
01/31/2024, 3:10 PMfun doStuff() = with(x) {
with(y) {
//...do stuff with y...
with(x) { /** do something with x */ }
}
}
Saharath Kleips
01/31/2024, 3:15 PMwith(x) { … }
every time I needed to disambiguate. Was hoping I could use a label or somethingKlitos Kyriacou
01/31/2024, 3:33 PMfun doStuff() = with(x) {
fun printX() = Unit.print()
with(y) {
Unit.print() // "From Y"
printX() // "From X"
}
}
Saharath Kleips
01/31/2024, 6:49 PM