Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Collection: Intersection & Union

Devrath edited this page Feb 29, 2024 · 1 revision

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

Clone this wiki locally

Morty Proxy This is a proxified and sanitized view of the page, visit original site.