https://kotlinlang.org logo
#atrium
Title
# atrium
d

dave08

07/23/2018, 1:05 PM
No, it's not a var...
r

robstoll

07/23/2018, 1:40 PM
Seems like my previous message was sent with a delay. The problem is that your property is dynamic (the
get ()
part not an assignment )
You could assign
cxt2.expected
to a local variable to circumvent the problem
d

dave08

07/23/2018, 8:12 PM
Even when I switched to lazy (no more get()...)?
r

robstoll

07/24/2018, 6:04 AM
I guess intelliJ does not track
lazy
as special case.
by
is delegation and as such re-called everytime. Hence the value could change from call to call
moreover,
lazy
could be unsynchronized in which case it theoretically could happen as well, that the first call returns non-null, where the second returns null
d

dave08

07/24/2018, 6:08 AM
And
lateinit var
would be better? I guess it's not such a big deal, but I'm still wondering about that if (.. is null) ..toBe(null) else ... Now that there's toBe(null), I should have been able to do w/o the extra if, no?
r

robstoll

07/24/2018, 6:09 AM
then it's a var and var could change from call to call
assign it to a local variable and all problems are solved 😉
kotlin can only make a smart cast if it is 100% sure and in all cases you showed it cannot be sure
d

dave08

07/24/2018, 6:22 AM
Ok... but I can't spare the
if
check in the first place (we spoke about this once, I just don't know if the recent changes now permit this...)?
r

robstoll

07/24/2018, 6:38 AM
no, I don't indent to add such
or
behaviour.
but you can still use the function I sent you back then
👍🏼 1
the only or I introduced in Atrium is
isLessOrEquals
which is kind of a special case which is OK IMO
2 Views