# encoding: utf-8 words = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.String"), "hello", "world", "kotlin", "android")) # 按单词长度分组 wordsByLength = words.groupBy(lambda { |it| $objectWrappers.wrap(it).count() }) { |it| it } # 输出:按长度分组的单词: {5=[hello, world], 6=[kotlin], 7=[android]} $console.log("按长度分组的单词: ", wordsByLength)