我正在手机上使用Grasshopper应用程序,但我不理解他们为if语句提供的示例。
他们给您解决方案,因为我回答不正确,但是我不明白为什么给出的解决方案正确。
var todayWeather = 'rainy';
var tommorrowWeather = 'cloudy';
if (todayWeather === 'rainy') {
print('Bring an umbrella');
}
if (todayWeather !== 'rainy') {
print('Maybe the sun will come out');
}
他们说正确的答案是“带伞”。但是为什么运行该代码会产生什么呢?
答案 0 :(得分:0)
将代码翻译成英语:
Bring an umbrella
Maybe the sun will come out
请注意,仅在满足条件时才执行打印语句。 同样,变量值在设置后也不会被该代码更改。