# encoding: utf-8 words = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.String"), "hello", "world", "kotlin")) # 迭代数组元素及其索引 words.withIndex().forEach { |it| $console.log("Index: ", it.index, "Word: ", it.value) } # 输出: # Index: 0, Word: hello # Index: 1, Word: world # Index: 2, Word: kotlin