Please consider this silly example:
if (1..3) { "true" }
The above produces the output true.
My question: How does the if statement handle a case like this where multiple values are output by the conditional? Is the "true" output the result of the "3" (the last case)? Or is some other logic at work? Thanks.
The observed behavior is explained (to some extent) in this blog post. Basically, if an expression evaluates to 0 it's interpreted as false, otherwise as true. Examples:
0 => False
1 => True
"0" => True (because it's a string of length 1)
"" => False (because it's a string of length 0)
@() => False
@(0) => False (this one's a little surprising)
@(0,1) => True
@("0") => True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With