What does this print?
String tag(String? s) {
final v = s ?? 'none';
return v.toUpperCase();
}
void main() {
print(tag('dart'));
print(' / ');
print(tag(null));
}
Try it in the online Dart Playground →
[spoiler title="Solution"]
Answer:
DART / NONE
Explanation:
The ?? operator provides ‘none’ as a default when s is null. v is thus a String which can be upcased.
[/spoiler]