Tsallaka zuwa abun ciki
Justice Tech School

Assignment and Null Aware Operators

+=, -=, *= and /= shorten updates. ??= assigns only if the variable is null. The cascade operator .. calls several things on one object.

Example
int? x;
x ??= 5;
x = x + 1;
var sb = StringBuffer()..write("a")..write("b");
print("$x $sb");

Exercise

Assign if null.

x  5;

Quiz Test

What does ??= do?

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