Subject: && operator in if statement
Date: 2016-02-23 08:04:31
From: Andrei Neagu
Source: operator-statement
----------------------------------------------------------------------

Hello,

I am using version 6.1.

I have a condition like this:

{%if color && color.Code && color.Name && SomeMethodFromCSharp(color.Name, color.Code) %}
            
{$ if %}

The issue I have is that if color is null, then "color.Code" is also computed and it throws an exception. This behavior is not simmilar to other languages, like C#, where if the first condition is false, then the second one is ignored.

Can you please take this into account for next versions ? Or is it already fixed in a newer one ? For now, I can do an if -> if -> if, but this can be difficult to mange sometimes.

Thank you!

 

---------------------------------------------------------------------- Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor who sold you the license and ask for your money back. Back to ComponentPro Q&A Forum Index