Question du test Flutter

A quoi sert l'opérateur `??=` en Flutter?

Très facile

A quoi sert l’opérateur ??=

Auteur: Edouard MarquezStatut : PubliéeQuestion passée 1677 fois
Modifier
3
Évaluations de la communauté
developer avatar
Réponse incorrecte
Auteur anonyme
18/08/2024
There is no ??= operator in Flutter/Dart Flutter and Dart use the ?? operator, not ??=. The ?? operator The ?? operator is the null-aware coalescing operator. It provides a concise way to check if an expression is null and return an alternative value if it is. Syntax: Dart expression1 ?? expression2 Use code with caution. Behavior: If expression1 is not null, the operator returns expression1. If expression1 is null, the operator returns expression2. Example: Dart String name = null; String displayName = name ?? 'Guest'; // displayName will be 'Guest' Use code with caution. Remember: There's no assignment involved with ??. It's solely for checking null values and providing alternatives.
developer avatar
Auteur anonyme
26/08/2024
Dart documentation mention the `??=` operator : https://dart.dev/language/operators#assignment-operators