We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents c63bd9a + 772a3c3 commit 3d64f51Copy full SHA for 3d64f51
docs/docs/reference/other-new-features/explicit-nulls.md
@@ -81,9 +81,10 @@ So far, we have found the following useful:
81
- An extension method `.nn` to "cast away" nullability
82
83
```scala
84
- def[T] (x: T|Null) nn: x.type & T =
85
- if x == null then new NullPointerException("tried to cast away nullability, but value is null")
86
- else x.asInstanceOf[x.type & T]
+ extension [T](x: T | Null)
+ inline def nn: T =
+ assert(x != null)
87
+ x.asInstanceOf[T]
88
```
89
90
This means that given `x: String|Null`, `x.nn` has type `String`, so we can call all the
0 commit comments