From 02524e046eed0cd668a557d2eeb34ee86bd811b9 Mon Sep 17 00:00:00 2001 From: Pratik Karki Date: Wed, 28 Feb 2018 20:19:58 +0545 Subject: Fix URLs --- zh-cn/dart-cn.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'zh-cn/dart-cn.html.markdown') diff --git a/zh-cn/dart-cn.html.markdown b/zh-cn/dart-cn.html.markdown index 6a6562bc..b0287f0c 100644 --- a/zh-cn/dart-cn.html.markdown +++ b/zh-cn/dart-cn.html.markdown @@ -492,8 +492,8 @@ main() { Dart 有一个综合性网站。它涵盖了 API 参考、入门向导、文章以及更多, 还包括一个有用的在线试用 Dart 页面。 -http://www.dartlang.org/ -http://try.dartlang.org/ +* [https://www.dartlang.org](https://www.dartlang.org) +* [https://try.dartlang.org](https://try.dartlang.org) -- cgit v1.2.3 From a54b3879ca5bbdee2b7eea5fb1896de91ea31db5 Mon Sep 17 00:00:00 2001 From: OKry Date: Sun, 18 Nov 2018 17:17:50 +0800 Subject: [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. --- zh-cn/dart-cn.html.markdown | 44 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) (limited to 'zh-cn/dart-cn.html.markdown') diff --git a/zh-cn/dart-cn.html.markdown b/zh-cn/dart-cn.html.markdown index b0287f0c..79db8e5c 100644 --- a/zh-cn/dart-cn.html.markdown +++ b/zh-cn/dart-cn.html.markdown @@ -176,23 +176,47 @@ example13() { match(s2); } -// 布尔表达式必需被解析为 true 或 false, -// 因为不支持隐式转换。 +// 布尔表达式支持隐式转换以及动态类型 example14() { - var v = true; - if (v) { - print("Example14 value is true"); + var a = true; + if (a) { + 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 { - if (v) { - // 不会执行 + if (b) { + print("Example14 true, b is $b"); } else { - // 不会执行 + print("Example14 false, b is $b"); } } 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 语句用于异常处理。 -- cgit v1.2.3