https://kotlinlang.org logo
#feed
Title
s

SiebelsTim

03/04/2019, 8:16 AM
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

marcinmoskala

03/04/2019, 8:22 AM
ow, yes
p

Pavlo Liapota

03/04/2019, 10:06 AM
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

Dico

03/04/2019, 10:45 AM
@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

Pavlo Liapota

03/04/2019, 10:51 AM
Yes, nullable type is a super type and the article in the summary states other way around.
d

Dico

03/04/2019, 10:57 AM
Ok
m

marcinmoskala

03/04/2019, 1:41 PM
Thanks @Pavlo Liapota Good points 🙂
👍 1
6 Views