Actionscript if / else 语法问题
以下哪项最能翻译英语句子“如果下雨,我们会看电影。否则我们会去公园。”
a. if (rainy = true) { gotoAndStop ("movie"); }
b. if (rainy == true) { gotoAndStop ("movie"); }
c. if (rainy = true) { gotoAndStop ("movie"); } else { gotoAndStop ("park"); }
d. if (rainy == true) { gotoAndStop ("movie"); } else { gotoAndStop ("park"); }
我的答案是“d”——正确吗?
Which of the following best translates the English statement "If it's rainy, we will watch a movie. Otherwise we will go to the park."
a. if (rainy = true) { gotoAndStop ("movie"); }
b. if (rainy == true) { gotoAndStop ("movie"); }
c. if (rainy = true) { gotoAndStop ("movie"); } else { gotoAndStop ("park"); }
d. if (rainy == true) { gotoAndStop ("movie"); } else { gotoAndStop ("park"); }
My answer would be "d" - is that correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,“d”是正确答案。
=
和==
之间的区别在于==
比较并返回一个布尔值(true 或 false),您可以对其进行操作(称为“分支”) ')。=
称为赋值运算符,虽然编写的代码完全有效,但通常不是您希望在 if 语句中使用的内容。基本上意味着“用 5 代替 x;如果 x 非零则调用 doStuff”。
另一件需要注意的事情是,当涉及到布尔值时,这样写会“更安全”
Yes, 'd' is the correct answer.
The difference between
=
and==
is that==
compares and returns a Boolean (true or false) which you operate upon (called 'branching').=
is called the assignment operator and while perfectly valid code to write, is not what you normally want to use in an if statement.Basically means "put 5 instead of x; if x is non-zero call doStuff".
Another thing to note is when it comes to booleans, it's "safer" to write
这也很酷:
This is cool too:
或者......试试这个,做同样的......但看起来很性感:)
or...try this, does the same.... but looks sexy :)