Expression evaluation order in if statement
Aarti_pl
aarti at interia.pl
Thu Aug 23 03:21:44 PDT 2007
Lutger pisze:
> Aarti_pl wrote:
>> Hello!
>>
>> Can I use if expression in following way, or is it an error?:
>>
>> void func(char[] str) {
>> if (str !is null && str=="somestring") {
>> ... some code ...
>> }
>> }
>
> It's ok, see: http://www.digitalmars.com/d/expression.html#AndAndExpression
>
> "If the left operand, converted to type bool, evaluates to false, then
> the right operand is not evaluated."
Great.
Thanks for advice!
BR
Aarti_pl
More information about the Digitalmars-d-learn
mailing list