How is `Any` or `Nothing` type mapped at runtime?
# announcements
a
How is
Any
or
Nothing
type mapped at runtime?
s
what do you mean?
Any
roughly corresponds to
Object
a
I mean, how does JVM deal with these types which are unknown to it
at compile time as per the docs.
s
using the Kotlin Bytecode view, it looks like
Nothing
turns into
Ljava/lang/Void
and
Any
turns into
Ljava/lang/Object
👍 1
Try it for yourself:
Copy code
val any: Any = ""
val nothing = null
Tools -> Kotlin -> Show Kotlin Bytecode
👍 1
a
difference that
Any
brings to the language?
c
I'm not aware of any deep details of
Any
vs
Object
, but it arguably sounds better than
Object
as a type.
Nothing
on the other hand is a different fruit: https://kotlinlang.org/docs/reference/java-to-kotlin-interop.html#translation-of-type-nothing
2
I highly recommend to watch this video:

https://youtu.be/Uizh2WlJtnk

Or read Kotlin in Action
👍 1
s
@Czar +1 for that link, didn’t realize that was covered in the docs
👍 1
c
Problem is some of it still isn't covered (at least I haven't seen it yet, but it is in the book and as far as I remember in the video I've shared)
I mean `Nothing`'s effect on the flow
👍 2
a
Awesome @Czar. Will take a look. TY.
c
Sure 🙂
Yup, confirmed, it is covered in the video, if you don't have time to watch it all, the Unit/Void/Nothing is covered starting from 12th minute
a
Will watch it all.
👍 1
Also, need to get the book. "Kotlin in action" right?
c
yup, written by the authors of the language and has a lot of information useful in practice