假设我在循环中有一个速记 if-else 语句,如本例所示:
for(...)
{
a = b == c ? b : c;
// More unnecessary code if the result was true.
}
我想通过条件的结果来打破循环:
for(...)
{
a = b == c ? b break : c;
// Now the unnecessary code is not executed.
}
我意识到我可以像这个例子一样完整地输入它:
for(...)
{
if( b == c )
{
a = b;
break;
}
else
{
a = c;
}
// Now the unnecessary code is not executed.
}
但它太长了,我试图在一行中包含每个中断条件,因为它们中有几个。