added T is nullable support

This commit is contained in:
sergeych committed 2026-03-14 20:57:15 +03:00
1 parent c54d947f1c
commit 37d093817e
9 files changed
+171 -11

No files matched your search

+12
View File
@@ -502,6 +502,18 @@ Aliases expand to their underlying type expressions. See `docs/generics.md` for
`Null` is the class of `null`. It is a singleton type and mostly useful for type inference results.
For type expressions, you can check nullability directly:
T is nullable
T !is nullable
This is especially useful in generic code and in `when` over a type parameter:
fun describe<T>(x: T): String = when (T) {
nullable -> "nullable"
else -> "non-null"
}
## Type inference
The compiler infers types from: