void main() {
int a = 10;
// int b = 5;
// b ??= 10;
// print(b);
String isBool = a > 5 ? "真" : "假";
print(isBool);
int c=1;
print(a ?? c);
}
??報(bào)錯(cuò) 。
main3.3.dart:11:9: Warning: Operand of null-aware operation '??' has type 'int' which excludes null.
print(a ?? c);
^
int a = 10;
// int b = 5;
// b ??= 10;
// print(b);
String isBool = a > 5 ? "真" : "假";
print(isBool);
int c=1;
print(a ?? c);
}
??報(bào)錯(cuò) 。
main3.3.dart:11:9: Warning: Operand of null-aware operation '??' has type 'int' which excludes null.
print(a ?? c);
^
2020-11-22
最新回答 / weixin_寶慕林1158390
相當(dāng)于做了判斷,只有是studet實(shí)例才會(huì)走到if內(nèi)部,反過來走到if內(nèi)部的一定是student,所以可以訪問student方法
2020-09-28
最新回答 / 劍起風(fēng)塵
意思是? var num = 23;? 那么此時(shí)num就是int類型,不能再賦值其他類型,即 num=‘a(chǎn)aa’此時(shí)將會(huì)報(bào)錯(cuò)。如果你之定義未賦值則是動(dòng)態(tài)類型,根據(jù)你實(shí)際使用中賦值的類型來確定num的類型,此時(shí)是可以改變值類型的。
2020-08-20