So, I can initialize a C array like this:
CGFloat colors[8]= {1,0.5,0.5, 1,
0.5,0.2,0.2, 1};
What if I want to define colors[8] but assign the 8 values conditionally. Is this possible? If it is, I cannot find the right syntax. Something like this:
CGFloat colors[8];
if (red){
colors= {1,0.5,0.5, 1,
0.5,0.2,0.2, 1};
}else
//assign colors to something else
I’ve tried various syntaxes but nothing works. I’m guessing it is not possible?
This will not work, as this way of assignment is only allowed at array initialization. what you can do is: