Tsallaka zuwa abun ciki
Justice Tech School

Null Safety

Types are non-nullable by default. Add ? to allow null and use ?., ?? and ! carefully.

Example
String? s;
print(s?.length);
print(s ?? "none");
s = "hello";
print(s.length);
int? n;
n ??= 5;
print(n);

Exercise

Default.

x  "none"

Quiz Test

What does String? allow?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.