Seth Madison
01/24/2024, 2:26 PMconst kotlinSet = new kotlin.Set(1,2,3)
or does it mean that Kotlin will now use native JS collections internally so that if I do:
val kotlinSet = Set(1.0, 2.0, 3.0)
that would compile to:
const kotlinSet = new Set(1,2,3)
ephemient
01/24/2024, 2:40 PMephemient
01/24/2024, 2:42 PM@JsExport
fun foo(): List<String> = listOf("a", "b", "c")
will be somewhat usable from JS,
const list = foo();
list.get(0) === "a";
Artem Kobzar
01/24/2024, 2:44 PMArtem Kobzar
01/24/2024, 2:44 PMArtem Kobzar
01/24/2024, 2:47 PM@JsExport
fun foo(): List<String> = listOf("a", "b", "c")
From the JS side there will be an ability to interact with at as with the regular JS array.
const result = foo() // KtList<string>
const resultAsArray = result.asReadonlyArrayView() // ReadonlyArray<string>
// So, all the JS array methods are available here
resultAsArray
.filter(x => x.charCodeAt() < "c".charCodeAt())
.map(x => String.fromCharCode(x.charCodeAt() + 1))
Artem Kobzar
01/24/2024, 2:47 PMArtem Kobzar
01/24/2024, 2:47 PMArtem Kobzar
01/24/2024, 2:48 PMfranztesca
01/24/2024, 2:49 PMArtem Kobzar
01/24/2024, 2:52 PMArtem Kobzar
01/24/2024, 2:53 PMEdoardo Luppi
01/24/2024, 3:21 PMArray
?franztesca
01/24/2024, 3:56 PMArtem Kobzar
01/24/2024, 4:05 PMEdoardo Luppi
01/24/2024, 4:12 PMEdoardo Luppi
01/24/2024, 4:15 PMEdoardo Luppi
01/26/2024, 2:32 PMList
, Map
and Set
.
So back to the list > array point, I don't think you can do that straight away.Edoardo Luppi
01/26/2024, 2:34 PMList
and MutableList
?
With the interface used in the signature of course.Edoardo Luppi
01/26/2024, 2:40 PMasJsArrayView
and asJsReadonlyArrayView
are default-implemented in the interfaces.Artem Kobzar
01/26/2024, 3:30 PM