Skip to content

Instantly share code, notes, and snippets.

@keyurgolani
Last active June 4, 2017 23:27
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 keyurgolani/f10330956b5d907dcb0d5ea5e446fd08 to your computer and use it in GitHub Desktop.
Save keyurgolani/f10330956b5d907dcb0d5ea5e446fd08 to your computer and use it in GitHub Desktop.
Kotlin Utility Functions Added to Builtin Classes for convenience.
fun List<Int>.isEqualTo(other: List<Int>): Boolean {
if (this.size != other.size) {
return false
}
return (0..this.size - 1).all { this[it].equals(other[it]) }
}
fun List<Int>.isNotEqualTo(other: List<Int>): Boolean {
if (this.size != other.size) {
return true
}
return (0..this.size - 1).any { !this[it].equals(other[it]) }
}
fun Int.toBigInteger(): BigInteger {
return BigInteger.valueOf(this.toLong())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment