prasham.h.trivedi
10/29/2018, 11:08 AMinline class State(val state: Int)
And in my regular class I have a variable of the State using Delegates.observable
.
Whenever I try to compare two states, I get : State cannot be cast to java.lang.Number
My sample comparision code looks like following.
this.state==State(1)
robin
10/29/2018, 11:51 AMthis.state == State(1).state
or
State(this.state) == State(1)
should work. That's exactly the use case for inline classes, that you can't accidentally cross-assign semantically different values, so you have to make it explicit.prasham.h.trivedi
10/29/2018, 11:55 AMState(this.state) == State(1)
Doesn’t seem to work.
My variable is
var state by Delegates.observable(State(0){
___
}
Usually state is being re-assigned.
Now at some point if I compare using
1.
state=State(0)
Or
state.state==0
Both gives ClassCastException
robin
10/29/2018, 12:04 PMrobin
10/29/2018, 12:05 PMprasham.h.trivedi
10/29/2018, 12:08 PMClassCastException
?prasham.h.trivedi
10/29/2018, 12:10 PMrobin
10/29/2018, 12:16 PMrobin
10/29/2018, 12:17 PMrobin
10/29/2018, 12:19 PMorangy
mikhail.zarechenskiy
10/29/2018, 1:29 PM