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

julioromano

06/17/2021, 1:30 PM
Why is there
mutableStateListOf
and 
mutableStateMapOf
but no
mutableStateSetOf
?
1
b

Big Chungus

06/17/2021, 1:32 PM
I'm guessing because collections are harder to diff and as such have more tailored and optimised variants for this.
a

Adam Powell

06/17/2021, 3:10 PM
feel free to file a FR, answer is probably as simple as, "we haven't needed it ourselves yet"
🙏 1
z

Zach Klippenstein (he/him) [MOD]

06/17/2021, 4:21 PM
Also you can trivially implement a set on top of a map (I believe this is actually how some of the standard JVM collections like
LinkedHashMap
do it)
a

Adam Powell

06/17/2021, 4:26 PM
all of the current ones are basically thin wrappers around a shaded version of kotlinx.collections.immutable collections
j

julioromano

06/17/2021, 10:22 PM
Also you can trivially implement a set on top of a map (I believe this is actually how some of the standard JVM collections like 
LinkedHashMap
 do it)
@Zach Klippenstein (he/him) [MOD] I though of that too, because the keys of a
Map
are indeed a
Set
. Though couldn’t come up with a simple way of declaring:
Copy code
val myCollection = remember { mutableStateMapOf<String, Long>() }
and then accessing
myCollection
as a
MutableSet
z

Zach Klippenstein (he/him) [MOD]

06/17/2021, 10:53 PM
Yea you’d have to probably manually implement the interface and delegate
471 Views