But the result of this script
Code: Select all
#Requires AutoHotkey v2
MsgBox !!"0"
MsgBox "0" ? true : false
Code: Select all
#Requires AutoHotkey v2
MsgBox !!"0"
MsgBox "0" ? true : false
Can you provide a link?CoolCmd wrote: ↑ According to the documentation, in places where boolean value is expected, string "0" is treated as true.
When an expression is required to evaluate to true or false (such as an IF-statement), a blank or zero result is considered false and all other results are considered true.
When a value is required to be either true or false, a blank or zero value is considered false and all other values are considered true.
If the If statement's expression evaluates to true (which is any result other than an empty string or the number 0)
Code: Select all
if (0 = "0")
MsgBox 1
but reading the if-statement documentation, it doesnt make any sense to me why that should be the casev2Changes/Types wrote:Quoted literal strings and strings produced by concatenating with quoted literal strings are no longer unconditionally considered non-numeric. Instead, they are treated the same as strings stored in variables or returned from functions. This has the following implications:
•Quoted literal "0" is considered false.
If the If statement's expression evaluates to true (which is any result other than an empty string or the number 0)
Code: Select all
if (0 = "0")
msg1 := " true : 0 = ""0"""
else
msg1 := " false : 0 does not = ""0"""
if (0 = "1")
msg2 := " true : 0 = ""1"""
else
msg2 := " false : 0 does not = ""1"""
if (0 = "00")
msg3 := " true : 0 = ""00"""
else
msg3 := " false : 0 does not = ""00"""
msgbox % msg1 "`n" msg2 "`n" msg3
return
Up to and not including?The == and !== operators can be used to compare strings which contain binary zero. All other comparison operators except ~= compare only up to the first binary zero.
No, it is generally the case that numeric strings can be evaluated numerically. In v1, there is the special case that quoted strings used immediately in an expression are treated as non-numeric, inconsistent with strings contained by variables. The documentation you quoted explains that this special case has been removed. Thus, there is no special case in v2, and the general case now applies to !!"0" just the same as it always applied to !!(x:="0").
0 and 0.0 are stored differently. They are not the same type, and yet they are of equal value.joefiesta wrote:For one, they are stored differently (I assume... Ionly know about mainframe inner workings).
If the expression evaluates to false (which is an empty string or the number 0)