Is there any reason Kotlin does not have a native ...
# announcements
d
Is there any reason Kotlin does not have a native Stack Data Structure?
s
Copy code
fun <E> MutableList<E>.push(element: E) = add(element)
fun <E> MutableList<E>.pop(element: E) = removeAt(lastIndex)
1
a stack by any other name
d
Yeah I guess I can add the peek function too.
t
well done. I ended up making my own set of interfaces to avoid the “3,293,484” functions exposed on the java stack classes
m
Also, you could complement @Shawn nice code with a typealias to have your
Stack