Très facile
A quoi sert l’opérateur ??=
Auteur: Edouard MarquezStatut : PubliéeQuestion passée 1658 fois
Modifier
3
Évaluations de la communauté
Réponse incorrecte
Auteur anonyme18/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.
Questions similairesPlus de questions sur Flutter