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

seq.list返回的数组无法修改 #187

Closed
hug3id opened this issue Dec 31, 2019 · 2 comments
Closed

seq.list返回的数组无法修改 #187

hug3id opened this issue Dec 31, 2019 · 2 comments
Labels

Comments

@hug3id
Copy link

hug3id commented Dec 31, 2019

版本 v4.2.8

执行以下表达式
list = seq.list(2);list[0] = 3;list[0]

结果返回2

@killme2008
Copy link
Owner

killme2008 commented Dec 31, 2019

目前还不支持类似 x[i]=y 这样的赋值,你可以暂时通过导入 List 类的实例方法来解决这个需求:

    AviatorEvaluator.addInstanceFunctions("list", List.class);
    Long result =
        (Long) AviatorEvaluator.execute("list = seq.list(2);list.set(list, 0, 3);list[0]");
    System.out.println(result);

调用了 List#set(index, value) 方法

导入函数可以参见文档

https://github.com/killme2008/aviator/wiki/%E8%B0%83%E7%94%A8-Java-%E6%96%B9%E6%B3%95%E5%92%8C-Function-Missing

@killme2008
Copy link
Owner

发布了 4.2.9(可能要等一段时间才能从 maven central 同步到),已支持 x[i] = y 这样的数组或者 List 赋值。

https://github.com/killme2008/aviator/releases/tag/aviator-4.2.9

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

No branches or pull requests

2 participants