Hullaballoonatic
06/19/2018, 7:16 PMfun <E> MutableCollection<E>.take(n: Int): Collection<E> {
val result = ArrayList<E>()
repeat(n) {
result += this.first()
remove(this.first())
}
return result
}
fun <E> MutableCollection<E>.takeLast(n: Int): Collection<E> {
val result = ArrayList<E>()
repeat(n) {
result += this.last()
remove(this.last())
}
return result
}
any recommendations?