Dims
Dims

Reputation: 51069

How to create List from Set in Kotlin?

Suppose I have a set with elements. How to create List of the same elements? I see methiods asSequence and asIterable, but no asList, why?

Upvotes: 16

Views: 8186

Answers (1)

s1m0nw1
s1m0nw1

Reputation: 81959

The function you're looking for is called toList():

val set: Set<Int> = setOf(1,2,3)
val list: List<Int> = set.toList()

Upvotes: 34

Related Questions