Last active
April 2, 2017 19:38
-
-
Save mg6maciej/8ca59b126458d5563398c5ee47ba592c to your computer and use it in GitHub Desktop.
Better implementation of Kotlin's minus extension function
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
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