Hello, I have a quick question. Does anyone knows ...
# getting-started
h
Hello, I have a quick question. Does anyone knows why Kotlin ArrayDeque does not have offerLast or offer series functions? (while Java ArrayDeque java has OfferLast) https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-array-deque/ https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/util/ArrayDeque.html
a
h
@Adam S not quite...
example, removeLast() throws exception when there is no element, while pollLast return null when there is no object 🧐
a
based on this answer https://stackoverflow.com/q/29092043/4161471 I would infer there’s no difference between
addLast()
and
offerLast()
even in the Java version of ArrayDeque
removeLast()
is equivalent to
removeLast()
, while
pollLast()
would be equivalent to
removeLastOrNull()
h
oh thanks. Do you know why this line is throwing error?
I thought ArrayDeque implements Deque 🧐
I would guess because Deque is JVM only
h
thanks!!
a
you’re welcome :)