as soon as you think of writing ‘OT:’ or ‘offtopic’ or ‘Not an OGL question’ in the header you really should post it somehere else…
i do know opengl, and im happy if im can help someone… with opengl. I use delphi, we dont have that syntax so it doenst bother me, but this is just a matter of taste, what do you want as an anwer? a gallup?
Yes, it is the famous ternary operator. Yes, most people don’t like it, because it’s somewhat easier to read an explicit if-else statement with proper indentation (particularly so if you’re just skimming over code).
There are cases where it can be used nicely.
Eg, instead of
if (whatever)
{
a[2ij+kk-j+20+c][yw+x]=0;
}
else
{
a[2ij+kk-j+20+c][yw+x]=1;
}
You could use
a[2ij+kk-j+20+c][yw+x]=(whatever?0:1);
In the first snippet it’s not immediately clear that the left hand sides of the assignment are equal. You need to look carefully. The second version doesn’t require any comparison as the left hand side exists only once.
Good for dodging typos.
Yeah, most people who despise it just haven’t used it much - it doesn’t look like anything they’ve used before and it just doesn’t sit well with them. Best thing to do is just suggest they give it a go for a while and see how they feel about it then. Everyone I’ve introduced it to has decided it’s a very useful construct.
And to bring us back on topic, here’s one good use for it: