Nested Conditionals (If Else)


Author
Message
Kolfers
Kolfers
Distinguished Member (3.6K reputation)Distinguished Member (3.6K reputation)Distinguished Member (3.6K reputation)Distinguished Member (3.6K reputation)Distinguished Member (3.6K reputation)Distinguished Member (3.6K reputation)Distinguished Member (3.6K reputation)Distinguished Member (3.6K reputation)Distinguished Member (3.6K reputation)
Group: Forum Members
Posts: 24, Visits: 137
Hi! 

I've been scratching my head a bit since I couldn't figure out why my code wasn't doing what I expected. 
After a bit of testing it seems to me that embedding IF conditionals within and IF-THEN-ELSE conditional leads to unwanted results, that is, the ELSE statement is not evaluated, could you confirm this? 

For instance, this works fine (value.g is set to 255)
 if(0) {values.r = 0; values.g = 0; values.b = 255}  else {values.r = 0; values.g = 255, values.b = 0;};

However, this doesn't work (value.g is never set)
 if(0) { if(1) {values.r = 0; values.g = 0; values.b = 255}; }  else {values.r = 0; values.g = 255, values.b = 0;};

To be clear, the code doesn't crash / break or give warnings, it's just that the else expression is never evaluated. 

Is there anything that I might be missing here? I tried different semicolon placements, but it didn't seem to make a difference.

Thanks,

Kerwin




GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Reading This Topic

Explore
Messages
Mentions
Search