Title
k

kenkyee

04/12/2017, 5:10 PM
Works fine if you do this: val parcelList = ParcelableUtils.createBooleanArrayList(parcel) as ArrayList<Boolean?> to force it, but the IDE thinks that the stuff on the right is a useless cast.
k

kirillrakhman

04/12/2017, 5:16 PM
you can do
val parcelList : ArrayList<Boolean?> = ParcelableUtils.createBooleanArrayList(parcel)
all in all, this is a long standing discussion. during development kotlin used to infer all java declarations as nullable by default. this caused so much pain (null checks,
?.
,
!!
everywhere) that the team decided to rvert this and introduced platform types
ArrayList<Boolean!>!
which means "I don't know if this is nullable or not, you decide". like everything in language design, it's a trade-off.
k

kenkyee

04/12/2017, 5:20 PM
ahhh...I missed that discussion. Thanks 🙂 Oddly, I prefer the "As" syntax because it reminds me of C#. The other way gets rid of the IDE warning though.