Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下有什么问题?
我在最后一行出现语法错误,就在 if 之后
模块 mytest
int n = if (3 > 2) 1; else 0;
谢谢,--丹尼斯。
Rascal 中的顶级声明(包括控制台中的声明)期望右侧有一个表达式,因此您需要改为:
int n = ( 3 > 2 ) ? 1 : 0;
如果您在函数内部,则允许的内容不一致,因此应该可以正常工作:
n = if (3 > 2) 1; else 0;
但是您上面的内容在这种情况下也不起作用。