I would like to create a while loop where it will keep running under one of two conditions, where the one chosen is determined as a conditional. For example, it would be something along the lines of while(if (c = true) a<b else b<a). Is there any simple syntax for this? Or would I have to go the brute way and do the following?
if (c = true)
{
while(a<b)
{
}
}
else
{
while(b<a)
{
}
}
You can take advantage of the short-circuit nature of boolean evaluations, and:
However, you might find this is difficult to read. Another approach might be to use the conditional operator: