https://kotlinlang.org logo
r

rrader

12/27/2018, 12:55 PM
In JavaScript we have
undefined
value, what is equivalent in Kotlin?
a

anton.bannykh

12/27/2018, 1:01 PM
If you need to pass this value to JS you could use this: https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.js/undefined.html
r

rrader

12/27/2018, 1:05 PM
ok, but how will be if
undefined
is sent from JS to Kotlin?
a

anton.bannykh

12/27/2018, 1:05 PM
If you are consuming some JS value, and it turns to be
undefined
it gets treated as
null
in most cases (e.g.
undefined ?: 1
yields
1
). You can still distinguish it from
null
using the
===
operator if you need to (e.g.
undefined !== null
)
r

rrader

12/27/2018, 1:06 PM
ok, thanks, what do you think about https://youtrack.jetbrains.com/issue/KT-29026 ?
a

anton.bannykh

12/27/2018, 1:29 PM
Hm... Not sure... Just to be clear, what prevents you from declaring an `Optional`/`Undefined` class yourself and using it the way you suggested? It doesn't seem to require any compiler support. Or is it just that you want that particular class to be added to the standard library?
r

rrader

12/27/2018, 1:39 PM
Yes, just to be added in stdlib, it is simple class but every library will have own clas if it will not be in stdlib
a

anton.bannykh

12/27/2018, 4:44 PM
Got it. Personally I don't like this approach due to the need to wrap arguments manually at the call site. Not that I have a better solution at the moment. =(
4 Views