I'm wondering what is the best way to deal with Mu...
# announcements
d
I'm wondering what is the best way to deal with MutableSet and Sets in Kotlin.
Copy code
import java.nio.file.Files
import java.nio.file.LinkOption
import java.nio.file.Path
import java.util.stream.Collectors


fun one(dir: Path) {
    val currentFiles = Files.list(dir).filter {
        Files.isRegularFile(it, LinkOption.NOFOLLOW_LINKS)
    }.map {
        it.fileName.toString()
    }.collect(Collectors.toSet())
    two(currentFiles, setOf<String>())
    //  ^^^^^^^^^^^^ Required Set, Found MutableSet
}

fun two(files: Set<String>, dirs: Set<String>) {
    // this is actually declared in Java, thus there is no distinction between Set and MutableSet
}