I want to pass `transform` to `toSet`

A MutableSet is a Set in the interface sense, so you don’t need a function which does that.

So a cast is really all it takes, it’s usually nicer to write it by typing the variable instead of the explicit cast:

val something: Set<String> = listOf("").mapTo(mutableSetOf()) { it }
1 Like