https://kotlinlang.org logo
Title
t

Trevor

11/14/2017, 8:13 PM
Yeah I just want the compiler to catch all my mistake for me, and this seemed like a real easy case for the compiler to check that for me
p

Pavlo Liapota

11/14/2017, 8:36 PM
@Trevor What about logins[0], should this also return nullable type Login? or throw checked exception as list can be empty? 🙂
t

Trevor

11/14/2017, 8:56 PM
Ah! You got me @Pavlo Liapota, from that perspective you're right, I would expect an exception. so
logins[0]?
would be the equivalent of
firstOrNull
?
p

Pavlo Liapota

11/14/2017, 9:10 PM
Such construction
logins[0]?
will be confusing when used together with operator
?.
Imagine
logins[0]?.name
, is it
logins[0]? . name
or
logins[0] ?. name