开发者

Anonymous arrays in BeanShell

开发者 https://www.devze.com 2022-12-21 04:56 出处:网络
Is there a syntax for declaring anonymous arrays in BeanShell?I would like to write code analogous to the following:

Is there a syntax for declaring anonymous arrays in BeanShell? I would like to write code analogous to the following:

print(Arrays.asList("cat", "dog"))

but BeanShell fails to find the "asList" method, presumably because it doesn't understand varargs.

As a workaround, I could write:

print(Arrays.a开发者_运维问答sList(new Object[]{"cat", "dog"}))

but that seems excessively verbose.

Is there a compact BeanShell syntax for anonymous arrays, e.g.:

print(Arrays.asList(["cat", "dog"]))

Is there a better way to go about solving this problem altogether?


Use beanshell2, which supports varargs:

http://code.google.com/p/beanshell2/issues/detail?id=13

0

精彩评论

暂无评论...
验证码 换一张
取 消