Is it possible to use JavaScript’s `>>` oper...
# javascript
b
Is it possible to use JavaScript’s
>>
operator in Kotlin/JS?
Currently, this is my dirty hack:
Copy code
inline infix fun Int.rsh(rhs: Int): Int = eval("$this >> $rhs")
g
Not sure, but what about standard
Int.shr()
?
I’ve checked,
Int.shr()
transpiles directly to
>>
b
When I use
x shr y
it says “Unresolved reference: shr”.
x
and
y
are `Byte`s.
g
But in your example function is for Ints, so Int.shr is the same. Why do you need bytes in JS? As I know there is no byte type in js. Anyway, Kotlin doesn't have full set of byte operators, you should check this post https://discuss.kotlinlang.org/t/when-does-bit-fiddling-come-to-kotlin/2249
b
I'm working with stuff like
Uint8Array
. Additionally, I'm trying to be platform-independent, so Kotlin types matter.
g
So for now just convert byte to int, like in “Workarounds for now” paragraph
😞 1
👍 1