# encoding: utf-8 dw = $objectWrappers.wrap($iterables.mutableListOf()) data = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.String"), "one", nil, "three", "four", nil)) # 将非空字符串转换为其长度,并添加索引信息, 带索引的非空字符串长度: [0_3, 2_5, 3_4] data.mapIndexedNotNullTo(dw) { |index, word| if word != nil then index.to_s + "_" + $objectWrappers.wrap(word).count().to_s else nil end }.forEach { |it| $console.log(it) }