https://kotlinlang.org logo
#compose
Title
# compose
e

eygraber

01/15/2023, 10:34 AM
Somewhat related question to above, when I use
key
I expect that if I have non unique keys amongst the invocations of
key
at that point in composition, then something will go wrong. However, it seems to work fine. What should I be looking out for there?
f

Filip Wiesner

01/15/2023, 11:15 AM
Documentation does not seem to mention what happens when
key
is not unique. Only that it needs to be unique 😄 Maybe it defaults to "positional key" if there are duplicates but that's just a guess.
e

eygraber

01/15/2023, 11:20 AM
That's what seems to be happening in my testing, but confirmation would be nice. Especially since this seems to be an intrinsic and I can't find the implementation 😅
m

myanmarking

01/16/2023, 1:52 AM
It has sth to do with hierarquy as well. Keys must be unique within the same level
e

eygraber

01/16/2023, 1:53 AM
I had non unique keys in the same level, but it seemed like they fell back to positional
z

Zoltan Demant

01/16/2023, 8:09 AM
I dont know if this is technically correct.. but I usually key a bunch of things that depend on a key, e.g. remember blocks that should all reset when the key changes (in contrast to specifying key for each one). Looking at this through that lens, it makes sense, I think? Even if two key blocks are next to each other, their positions will differ and as such make them unique. I dont know if this is true, but thats how I think about them, perhaps you can share a bit more about your usage?
5 Views