M8Test Help

mapTo

val dw = mutableListOf<Int>() val numbers = arrayOf(1, 2, 3, 4, 5) // 将每个元素乘以 2, 翻倍后的数字: [2, 4, 6, 8, 10] numbers.mapTo(dw) { it * 2 }.forEach { _console.log(it) }
def dw = $objectWrappers.wrap($iterables.mutableListOf()) def numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Integer"), 1, 2, 3, 4, 5)) // 将每个元素乘以 2, 翻倍后的数字: [2, 4, 6, 8, 10] numbers.mapTo(dw) { it * 2 }.forEach { $console.log(it) }
let dw = $objectWrappers.wrap($iterables.mutableListOf()) let numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Integer"), 1, 2, 3, 4, 5)) // 将每个元素乘以 2, 翻倍后的数字: [2, 4, 6, 8, 10] numbers.mapTo(dw, it => it * 2).forEach((it) => { $console.log(it) })
local dw = _objectWrappers:wrap(_iterables:mutableListOf()) local numbers = _objectWrappers:wrap(_arrays:arrayOf(_plugins:loadClass("java.lang.Integer"), 1, 2, 3, 4, 5)) -- 将每个元素乘以 2, 翻倍后的数字: [2, 4, 6, 8, 10] numbers:mapTo(dw, function(it) return it * 2 end) :forEach(function(it) _console:log(it) end)
<?php $dw = $objectWrappers->wrap($iterables->mutableListOf()); $numbers = $objectWrappers->wrap($arrays->arrayOf($plugins->loadClass("java.lang.Long"), 1, 2, 3, 4, 5)); // 将每个元素乘以 2, 翻倍后的数字: [2, 4, 6, 8, 10] $numbers->mapTo($dw, function ($it) { return $it * 2; })->forEach(function ($it) use ($console) { $console->log($it); });
dw = _objectWrappers.wrap(_iterables.mutableListOf()) numbers = _objectWrappers.wrap(_arrays.arrayOf(_plugins.loadClass("java.lang.Long"), 1, 2, 3, 4, 5)) # 将每个元素乘以 2, 翻倍后的数字: [2, 4, 6, 8, 10] numbers.mapTo(dw, lambda it: it * 2).forEach(lambda it: _console.log(it))
# encoding: utf-8 dw = $objectWrappers.wrap($iterables.mutableListOf()) numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Long"), 1, 2, 3, 4, 5)) # 将每个元素乘以 2, 翻倍后的数字: [2, 4, 6, 8, 10] numbers.mapTo(dw) { |it| it * 2 }.forEach { |it| $console.log(it) }
Last modified: 09 September 2025