1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-01-17 21:49:22 +01:00

[dart/zh-cn]Fix bool convert of chinese version.

Same to my last commit of english version, fix bool implicit conversions support of chinese version.
This commit is contained in:
OKry 2018-11-18 17:17:50 +08:00 committed by GitHub
parent 44537874c3
commit a54b3879ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -176,23 +176,47 @@ example13() {
match(s2); match(s2);
} }
// true false //
//
example14() { example14() {
var v = true; var a = true;
if (v) { if (a) {
print("Example14 value is true"); print("Example14 true, a is $a");
} }
v = null; a = null;
if (a) {
print("Example14 true, a is $a");
} else {
print("Example14 false, a is $a"); //
}
// null可以转换成bool型
var b;// b是动态类型
b = "abc";
try { try {
if (v) { if (b) {
// print("Example14 true, b is $b");
} else { } else {
// print("Example14 false, b is $b");
} }
} catch (e) { } catch (e) {
print("Example14 null value causes an exception: '${e}'"); print("Example14 error, b is $b"); //
} }
b = null;
if (b) {
print("Example14 true, b is $b");
} else {
print("Example14 false, b is $b"); //
}
// null不能转换成bool型
var c = "abc";
c = null;
//
// if (c) {
// print("Example14 true, c is $c");
// } else {
// print("Example14 false, c is $c");
// }
} }
// try/catch/finally throw // try/catch/finally throw