Comments (6)
你好,能否将问题具体一些?或者给一段可以重现的代码。
from aviatorscript.
Expression compiledExp = AviatorEvaluator.compile("standardValue == compareValue");
Map<String, Object> params = new HashMap<String, Object>();
params.put("standardValue", 8161);
params.put("compareValue", "PCV3-8");
System.out.println(compiledExp.execute(params));
from aviatorscript.
我修改源码 AviatorNumber:
希望能给个正确修改的版本。
if (otherValue instanceof Number) {
return this.innerCompare(AviatorNumber.valueOf(otherValue));
} else if (otherValue instanceof String) {
return new AviatorString(String.valueOf(number)).compare(other, env);
} else {
throw new ExpressionRuntimeException("Could not compare " + this + " with " + other);
}
from aviatorscript.
这个错误是符合预期的,你传入的是数字和字符串,两者比较就是要报错的。
具体比较规则参见文档
https://github.com/killme2008/aviator/wiki#%E5%85%B3%E7%B3%BB%E8%BF%90%E7%AE%97%E7%AC%A6
from aviatorscript.
针对这个问题,你有几个解决办法:
- 保证传入的类型是相同的,也就是传入之前对 standardValue 做 toString 处理。
- 可以用
str
函数将某个值强制转成字符串来比较str(standardValue) == compareValue
。
from aviatorscript.
谢谢
from aviatorscript.
Related Issues (20)
- 微信群二维码过期是否可以更新一下
- 通过take_while获取集合中符合条件的数组后,取其中某个元素的属性报错,用了引用变量也不行
- 🩵
- [建议]支持null-safety引用变量 HOT 4
- Compile能否提前发现某些Function不可用? HOT 1
- 版本4.2.5 jdk版本openjdk11 HOT 1
- 是否有计划支持java AOT HOT 1
- 【咨询】自定义函数脚本如何获取到env信息? HOT 1
- Prediteur
- 关于复杂表达式性能优化问题请教 HOT 1
- context污染的问题 HOT 1
- com.googlecode.aviator.runtime.function.FunctionUtils 方法报错问题 HOT 2
- 利用“字符串插值”特性替代模板引擎时出现问题,请教 HOT 5
- 输入错误aviator表达式导致metaspace oom HOT 3
- 服务中能维护几百个AviatorEvaluatorInstance吗? HOT 2
- com.googlecode.aviator HOT 1
- 请问,连续表达式计算时"d=a/b; d+c",当a=10, b=0,c=5时,计算结果希望等于5,如何解决?
- 编译表达式解析不出表达式的变量 HOT 3
- 动态生成大量不同的aviator表达式导致metaSpace OOM,FGC无法正确回收 HOT 7
- Supports cancellation or timeout for executing expressions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aviatorscript.