1

Nested Ternary Operator question

Hey everyone,

I'm attempting to make some buttons that change the size and content of a cell based on how many are turned on, there are 5 buttons, and the cell can be filled and resized with different content based on which buttons are pressed. I'm using variables to save if a switch is turned on or off (adding +1 or -1 to a variable) then I am performing a check and if that variable is 1, change to this height, etc.

The operator I'm using opens but not to the correct height as I believe you cannot handle Nested Ternary Operators. Here is the check I'm performing and if you could tell me if it works or doesn't work that would be great, or maybe I'm just doing something incorrectly here.

{(cell_height = 0) ? 90  : (cell_height = 1) ? 150 : (cell_height = 2) ? 210 : (cell_height = 3) ? 270 : (cell_height = 4) ? 330 : (cell_height = 5) ? 390 : 0 }

Thanks!

5 comments

Please sign in to leave a comment.