Skip to content

35 Safe access ​

?. reads a member only when its receiver exists.

norm
class Task {
  String title
}

main() {
  Task? missing = null
  Task? present = Task(title: "Learn Norm")
  printLine(missing?.title == null)
  printLine(present?.title)
}

Expected output:

text
true
Learn Norm

For missing, missing?.title evaluates to null without reading a field. For present, it produces the task title; the overall expression remains nullable.

Try it: Add a second nullable member and chain two safe accesses.

Precise rules: Reference.

Norm 0.25