Whats ?? = Dart中的运算符 [英] Whats ??= operator in Dart
本文介绍了Whats ?? = Dart中的运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我在Flutter源代码中看到的新赋值运算符:
This is the new assignment operator I see in Flutter source code:
splashFactory ??= InkSplash.splashFactory;
textSelectionColor ??= isDark ? accentColor : primarySwatch[200];
这个赋值运算符是什么意思?
what's the meaning of this assignment operator?
推荐答案
?? =是一个新的可识别null的运算符.具体地说,?? =是可识别空值的赋值运算符.
??= is a new null-aware operators. Specifically ??= is null-aware assignment operator.
??如果为null运算符.
expr1 ??如果不是
的结果为null
,则expr2expr1
,否则为expr2
.
?? if null operator.
expr1 ?? expr2
evaluates toexpr1
if notnull
, otherwiseexpr2
.
?? =空感知分配.
v ?? = expr
导致分配v
仅当v
为null
时,expr
.
?.空感知访问.如果
x
不是null
,则x?.p
的值为xp
,否则为null 代码>.
?. null-aware access.
x?.p
evaluates tox.p
ifx
is notnull
, otherwise evaluates tonull
.
这篇关于Whats ?? = Dart中的运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文