<https://blog.kotlin-academy.com/the-beauty-of-kot...
# feed
s
The same is true about when: The closest supertype of String, String and Nothing is Nothing?
It should be String, String and Nothing? -> String?, right?
m
ow, yes
p
And in the summary:
Non-nullable type is a supertype of the nullable one
Should be other way around.
When function declares Nothing as a return type, it means that it will throw an error
Not necessary. You can also declare function with
Nothing
return type and have an infinite loop inside.
When an expression declares Nothing as a return type, everything surely executed after that will be unreachable
I would not say everything here. If this expression is inside
try-catch
block, then everything after this block is reachable. Also
continue
and
break
expressions return
Nothing
too, but only code after them and until loop’s end is unreachable.
d
@Pavlo Liapota I think the nullable type is a super type of the non null type. You cant assign a null value to a non-null typed variable, thus, the non-null has to be the subtype.
Why would it be the other way around?
p
Yes, nullable type is a super type and the article in the summary states other way around.
d
Ok
m
Thanks @Pavlo Liapota Good points 🙂
👍 1