📅  最后修改于: 2022-03-11 14:48:03.877000             🧑  作者: Mango
In other languages we can use the logical-or shortcut. If maybeSomeNumber()
returns null, assign a default value of 2:
value = maybeSomeNumber() || 2
In Dart we can’t do this because the expression needs to be a boolean (“the
operands of the || operator must be assignable to bool").
That’s why the ?? operator exists:
var value = maybeSomeNumber() ?? 2;