The third option is also simple, albeit something that the W3C folks really should have put into the specification. Listing 5 gives a simple boolean type definition
第三种选择也很简单,尽管W3C那帮人实际上应该把这一条放在规范中说明。
One of the biggest surprises for programmers coming from other languages is that, in Lua, only false and nil are considered false; any object of a non-boolean type is always considered true in tests.
对于习惯使用其他语言的程序员来说,Lua最令人惊讶的地方是,只有false和nil 被看作 false;任何非boolean类型的对象总是被看作true。
Because there are only two possible values, the Boolean type is unique.
因为只有两个可能值,所以布尔类型是惟一的。
In Listing 5, the test does not need to compare to a string because the variable returns a Boolean type rather than an RTF as a result of the select attribute.
在清单5中,测试不需要与字符串进行比较,因为变量返回一个Boolean类型而不是rtf作为select属性的结果。
In Listing 5, the test does not need to compare to a string because the variable returns a Boolean type rather than an RTF as a result of the select attribute.
在清单5中,测试不需要与字符串进行比较,因为变量返回一个Boolean类型而不是rtf作为select属性的结果。
应用推荐