Hi, is there anything in Kotlin, which will allow ...
# announcements
s
Hi, is there anything in Kotlin, which will allow me to alias Long, but in a way that it is not implicitly converted, so I never mix Long and my own type?
s
s
Thanks, overlooked that
And what about arrays of it? What's the syntax?
s
arrays of.. inline classes? what seems to be the issue?
d
You'll want another inline class.
inline class MyTypeArray(val array: LongArray)
. I'm assuming your talking about avoiding boxing.
s
Thanks, checking to see how it compiles.
Unfortunately,
Array<MyPrimitive>
is array of boxed types, and
inline class MyPrimitiveArray(val z: LongArray)
does not support array operations
so
val a = MyPrimitiveArray(LongArray(30)); val sz = a.size
is not working
d
You have to implement the array functionality yourself. (Someone should make a compiler plugin). Have a look at
ULongArray
.
s
ok, and how do i add .map and stuff?
d
Implement
Collection<MyPrimitive>
.
s
i see, looking at it. Thank you very much!