In JavaScript we have `undefined` value, what is e...
# multiplatform
r
In JavaScript we have
undefined
value, what is equivalent in Kotlin?
a
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
ok, but how will be if
undefined
is sent from JS to Kotlin?
a
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
ok, thanks, what do you think about https://youtrack.jetbrains.com/issue/KT-29026 ?
a
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
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
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. =(