Dev study and notes

[dart] #18 #3.4 QQ Operator (05:09) 본문

studyLog

[dart] #18 #3.4 QQ Operator (05:09)

devlunch4 2023. 5. 3. 05:59
반응형
String capitalizeName(String? name) => name?.toUpperCase() ?? 'ANON';

void main() {
    print(capitalizeName('canada'));
    print(capitalizeName(null));
    //
    String? name;
    name ??= 'lunch';
    name ??= 'another';
    print(name);
    name = null;
    name ??= 'another2';
    print(name);
}

// PRINT
// >>>
// CANADA
// ANON
// lunch
// another2
반응형
Comments