嗨,我是新手,被卡住了...
我该如何在dart中执行此javascript任务? https://www.w3schools.com/js/tryit.asp?filename=tryjs_continue
我正在尝试在-7至7之间跳过dart中for循环的0(零,零)
HTML页面:
<p>A loop which will skip the step where i = 3.</p>
<p id="demo"></p>
<script>
var text = "";
var i;
for (i = 0; i < 10; i++) {
if (i === 3) {
continue;
}
text += "The number is " + i + "<br>";
}
document.getElementById("demo").innerHTML = text;
</script>
</body>
</html>
Dart代码:
void main() {
var ii;
for (ii = -7; ii < 8; ii++) {
if (ii = 0) {
continue;
}
}
}
答案 0 :(得分:0)
如果尝试,您的飞镖代码甚至不会运行:在if (ii = 0) {
这行上,您会收到Conditions must have a static type of 'bool'.
错误。只需将等号运算符与==
一起使用,它将等于if (ii == 0) {
。