Scratching my head. I'm copy/pasting some previous...
# getting-started
t
Scratching my head. I'm copy/pasting some previous code I prototyped, using a LazyColumn and the items() builder like so:
Copy code
items(items = sortedPlans, key = { plan -> plan.oid })
oid is just a UInt. However, this fails. Digging through Logcat, I find this gem:
Copy code
java.lang.IllegalArgumentException: Type of the key 2 is not supported. On Android you can only use types which can be stored inside the Bundle.
Going back and looking at what I was doing before, I actually had a Pair there. So I just changed the above code to first:
Copy code
items(items = sortedPlans, key = { plan -> 'p' to plan.oid })
and that worked!?! As did this:
Copy code
items(items = sortedPlans, key = { plan -> plan.oid.toInt() })
What strange magic is this? I can't use a UInt? But I can if I wrap it in a pair? Why would that be the case?
e
kotlin.Pair
implements
java.io.Serializable
on JVM, which makes it pass the saveable test
of course it'll fail at runtime because the
UInt
wrapper class isn't serializable, but the generic Pair class can't know that
t
But it didn't fail at runtime, it worked
e
it doesn't get saved actually saved to a bundle until the app need to be stopped
t
like on a rotate?