What does this code output?
void main() {
String? a = null;
String? b = 'Hi';
print(a ?? b ?? 'Bye');
}
Try it in the online Dart Playground →
[spoiler title="Solution"]
Answer:
Hi
Explanation:
The ?? operator chains left-to-right. a is null, so it checks b which is ‘Hi’.
[/spoiler]