是否有可能在 Arduino 中的 while-Loop 之后添加一个 else,就像在 Java 或 C# 中一样?像这样:
while(condition){
doThingA;
} else{
doThingB;
}
最佳答案
C# 没有 while...else
而且我认为 Java 也没有这种结构。 Python 有它,因为 else
block 中的指令仅在您从循环中中断时才执行,您可以如下模拟它:
bool flag = TRUE;
while (condition)
{
if (anothercondition)
{
flag = FALSE;
break;
}
}
if (flag)
{
...
}
关于arduino - while...else Arduino 声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37837093/