Giter Site home page Giter Site logo

Comments (6)

killme2008 avatar killme2008 commented on September 13, 2024

你好,能否将问题具体一些?或者给一段可以重现的代码。

from aviatorscript.

viplq avatar viplq commented on September 13, 2024

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.

viplq avatar viplq commented on September 13, 2024

我修改源码 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.

killme2008 avatar killme2008 commented on September 13, 2024

这个错误是符合预期的,你传入的是数字和字符串,两者比较就是要报错的。

具体比较规则参见文档

https://github.com/killme2008/aviator/wiki#%E5%85%B3%E7%B3%BB%E8%BF%90%E7%AE%97%E7%AC%A6

from aviatorscript.

killme2008 avatar killme2008 commented on September 13, 2024

针对这个问题,你有几个解决办法:

  1. 保证传入的类型是相同的,也就是传入之前对 standardValue 做 toString 处理。
  2. 可以用 str 函数将某个值强制转成字符串来比较 str(standardValue) == compareValue

from aviatorscript.

viplq avatar viplq commented on September 13, 2024

谢谢

from aviatorscript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.