-
Notifications
You must be signed in to change notification settings - Fork 0
Boolean_Literals
The strings 'true' and 'false' are valid boolean literals.
Numbers are also valid literals, and all of them are false.
However, floating point numbers are only valid if they do not begin
with a period.
Invalid literals are allowed, but they are silently ignored.
- 'true'
- '0'
- '-0.5'
- '123456'
- 'True'
- 'TRUE'
- '.5'
- 'hello'
- '' (empty string)
- Boolean literals are case sensitive!
- All valid numbers are
false, even 1!
Literals should either be valid or they should not be valid. If they are not valid, then they should not be legal. They should at least generate a warning.
Literals should be case insensitive, and they should be valid if and only if they are sensible. Some or all of the following should be valid.
- '1' and '0'
- 'yes' and 'no'
- 'on' and 'off'
Vague and non-intuitive notions should be avoided.
For example, in contrast to JavaScript and C language rules, the
length of the literal should be irrelevant, and non-zero values
(other than 1) should not be true.
See Boolean Literals test for details.