如果动作/其他语法问题 [英] Actionscript if / else syntax Question

查看:85
本文介绍了如果动作/其他语法问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下哪个最好翻译英文语句如果是下雨,我们会看电影。否则,我们将去公园。

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"); }

我的答案是D - 是正确的。

My answer would be "d" - is that correct?

推荐答案

是的,D是正确答案。

和之间 = 的区别 == == 进行比较,并返回一个布尔值(true或false),你在(所谓的分支)运营。

The difference between = and == is that == compares and returns a Boolean (true or false) which you operate upon (called 'branching').

= 被称为赋值运算符,虽然完全有效的code写的,是不是你通常需要在if语句中使用。

= is called the assignment operator and while perfectly valid code to write, is not what you normally want to use in an if statement.

if(x = 5) {
    doStuff();
}

基本上意味着5而不是x的;如果x非零电话doStuff

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

if (rainy) {
    gotoAndStop("movie");
} else {
    gotoAndStop("park);
}

这篇关于如果动作/其他语法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆