Last active
May 17, 2019 02:43
-
-
Save stefanJi/82430a3a821d2819c5b116d92c46c412 to your computer and use it in GitHub Desktop.
Kotlin 两个集合的差集
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns a list of all the elements that are not included in this collection and that are not included in the specified collection. | |
*/ | |
public fun <T> Iterable<T>.subtractX(other: Iterable<T>): List<T> { | |
return filterNot { other.contains(it) } + other.filterNot { contains(it) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment