Dmitry Kandalov
12/08/2017, 11:34 AMpush()/pop()
items?
This seems like a basic thing for JS interop but I did't find any obvious solutions (kotlin.Array
doesn't have push()/pop()
methods).
The most reasonable solution I found was to define external JsArray class:
@JsName("Array")
external class JsArray<T> {
val length: Int
fun push(item: T)
fun pop(): T
operator fun get(index: Int): T
operator fun set(index: Int, value: T)
}
(If this is the right thing to do, shouldn't it be in kotlinjs stdlib and mentioned somewhere in docs? 🤔)konsoletyper
12/08/2017, 11:36 AMinline fun <T> Array<T>.push(e: T): Int = asDynamic().push(e)
snrostov
12/08/2017, 11:37 AMkotlin.Array
is fixed in java.Dmitry Kandalov
12/08/2017, 11:39 AMnatpryce
12/08/2017, 11:49 AMkonsoletyper
12/08/2017, 11:50 AMpush
on that array