littlelightcz
05/19/2019, 6:57 PMval foo = AtomicInteger(0)
foo++
Current increment
operator would allow me to work only with var foo
, but this is obviously not what I want. In my use case I want to launch N coroutines and show a progress bar with how many of them have already finished (tracked in the foo
AtomicInteger)Matej Drobnič
05/19/2019, 7:44 PMadd(Integer)
work?Matej Drobnič
05/19/2019, 7:44 PM++
is basically shorthand for += 1
Ruckus
05/20/2019, 12:44 AMinc
and dec
operators):
They shouldn't mutate the object on which thehttps://kotlinlang.org/docs/reference/operator-overloading.htmlorinc
was invoked.dec
littlelightcz
05/20/2019, 6:10 AMfoo += 1
littlelightcz
05/20/2019, 6:12 AMelizarov
05/20/2019, 8:30 AMlittlelightcz
05/20/2019, 9:25 AMRuckus
05/20/2019, 1:47 PMRuckus
05/20/2019, 1:48 PMclass Thing {
operator fun inc() { ... }
}
class MutableThing : Thing() {
operator fun mutableInc() { ... }
}
littlelightcz
05/20/2019, 3:22 PMRuckus
05/20/2019, 4:03 PM++
) for both inc
and mutableInc
, you would have to resolve the conflict I showed above (what would MutableThing()++
do?). If you also intended a new symbol, did you have one in mind?elizarov
05/20/2019, 4:39 PMa += b
that works both for mutable classes via a.plusAssign(b)
and for immutable classes via a = a.plus(b)
. If something in that direction is done for ++
, then it has to have similar design or it is a no-go.Ruckus
05/20/2019, 4:48 PMlittlelightcz
05/25/2019, 10:38 AM