Skip to content

Instantly share code, notes, and snippets.

@mg6maciej
Last active April 2, 2017 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mg6maciej/8ca59b126458d5563398c5ee47ba592c to your computer and use it in GitHub Desktop.
Save mg6maciej/8ca59b126458d5563398c5ee47ba592c to your computer and use it in GitHub Desktop.
Better implementation of Kotlin's minus extension function
fun <T> List<T>.betterMinus(other: List<T>): List<T> {
return if (other.isEmpty()) {
this
} else {
(this - other.first()).betterMinus(other.subList(1, other.size))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment