Reputation: 1855
Simple example
Intellij uses !
in NotNull type's type hint.
However, it is against the kotlin syntax. Why does Intellij ignore the syntax of kotlin that they created?
Upvotes: 0
Views: 111
Reputation: 10723
It's because LocalDate
belongs to Java API, not to Kotlin, and now
is not annotated with @NotNull
or one of the other supported annotations (here's the complete list).
Because of that, Kotlin doesn't know if the returned value might (not) be null
, so it marks the type with !
(as described here).
In the second example, you "force" the type to be not-nullable (as described here), but this will cause an exception to be thrown if the real value is actually null
.
Upvotes: 6