Types syntax

Type? and Type!

Nullable and non-null reference type suffixes.

Type? marks a nullable reference; Type! marks non-null with compile-time checks. Plain Type is a platform type (Java-like, no enforced nullability). Assigning null to Type! is a compile error.

Affogato

example.aff
var name: String! = "Alex"
var email: String? = null

// Compile error:
// var bad: String! = null

Generated Java

Example.java
@dev.affogato.annotations.NotNull
String name = "Alex";
@dev.affogato.annotations.Nullable
String email = null;

Related

See also

← All keywords