https://kotlinlang.org logo
#announcements
Title
# announcements
p

poohbar

07/27/2017, 4:54 PM
when I have some incoming platform type like so:
Copy code
val header = request.getHeader("xyz")
I see that
header
has an inferred type of
String!
... is this okay? what happens if
getHeader
returns
null
?
d

diesieben07

07/27/2017, 5:00 PM
If
getHeader
returns
null
and you try to call something on
header
, you get a
NullPointerException
.
If you declare
header
as
String
explicitly, you will get the NPE immediately on assignment instead.
p

poohbar

07/27/2017, 5:27 PM
I see. Thank you.
2 Views