toCollection

fun <T : Any, C : MutableCollection<in T>> Optional<T>.toCollection(destination: C): C(source)

Appends this Optional's value to the given destination collection if present.

Since Kotlin

1.8