# encoding: utf-8 words = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.String"), "hello", "world", "kotlin")) # 从右到左连接所有单词,并添加索引信息 joinedString = words.foldRightIndexed("") { |index, word, acc| acc.to_s + index.to_s + "_" + word + " " } # 输出:连接后的字符串: 2_kotlin 1_world 0_hello $console.log("连接后的字符串: ", joinedString)