Collection: Intersection & Union - devrath/KotlinAlchemy GitHub Wiki
code
val numList1 = mutableListOf(
1,2,3
)
val numList2 = mutableListOf(
1,2,3,4
)
fun main(args: Array<String>) {
val result = numList1.union(numList2)
result.forEach {
println(it)
}
println("<---------------->")
val result2 = numList1.intersect(numList2)
result2.forEach {
println(it)
}
}Output
1
2
3
4
<---------------->
1
2
3