# encoding: utf-8 words = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.String"), "hello", "world", "kotlin")) # 打印每个单词及其索引,并返回原始数组 result = words.onEachIndexed { |index, word| $console.log("Index: ", index, "Word: ", word) } # 输出:结果: [Ljava.lang.String;@... $console.log("结果: ", result) # 同时打印: # Index: 0, Word: hello # Index: 1, Word: world # Index: 2, Word: kotlin