Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.googlecode.aviator.runtime.function.FunctionUtils 方法报错问题 #619

Closed
zimingFan opened this issue Apr 3, 2024 · 2 comments
Closed

Comments

@zimingFan
Copy link

Uploading 捕获.PNG…
此段代码如果输出的结果是非 String 类型 的数据会报错,因为无法强转,建议改为

/**

  • Get string value from env.
  • @param arg the var name
  • @param env
  • @return
    */
    public static final String getStringValue(final AviatorObject arg,
    final Map<String, Object> env) {
    final Object value = arg.getValue(env);
    if(value != null){
    return value.toString();
    }
    return null;
    }
@zimingFan
Copy link
Author

当然详细的内容我并没有测试,这个例子并不知道会产生什么后果,,仅供参考

@killme2008
Copy link
Owner

这个方法就是假设你传入的参数是字符串,如果不是,请自己明确去转换,比如自己实现一个 to_string 方法。
隐式转换带来的 bug 将很难查。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants