private String boundaries = "(x > 750) & (x < 900)";
if (boundaries) {
//Do stuff
}
Run Code Online (Sandbox Code Playgroud)
我希望能够在if子句中使用字符串作为变量,然后独立更改字符串,而无需编辑代码本身.示例的想法不起作用,我想知道它是否有错误或其他方式不使用字符串.
谢谢.
我想对一个列表进行排序,其中包含所需的行为
input: [-2, 1, 4, -5]
output: [1, -2, 4, -5]
Run Code Online (Sandbox Code Playgroud)
将其作为字符串列表处理不起作用,并且在返回时也不将其视为整数列表
string: [-2, -5, 1, 4]
ints: [-5, -2, 1, 4]
Run Code Online (Sandbox Code Playgroud)
有关如何获得所需行为的任何指示?