Thread
#multiplatform
    r

    rrader

    3 years ago
    In JavaScript we have
    undefined
    value, what is equivalent in Kotlin?
    anton.bannykh

    anton.bannykh

    3 years ago
    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

    3 years ago
    ok, but how will be if
    undefined
    is sent from JS to Kotlin?
    anton.bannykh

    anton.bannykh

    3 years ago
    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

    3 years ago
    ok, thanks, what do you think about https://youtrack.jetbrains.com/issue/KT-29026 ?
    anton.bannykh

    anton.bannykh

    3 years ago
    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

    3 years ago
    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
    anton.bannykh

    anton.bannykh

    3 years ago
    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. =(