M8Test Help

forEach

val numbers = arrayOf(1, 2, 3, 4, 5) // 打印数组中的每个元素 numbers.forEach { _console.log(it) } // 输出: // 1 // 2 // 3 // 4 // 5
def numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Integer"), 1, 2, 3, 4, 5)) // 打印数组中的每个元素 numbers.forEach { $console.log(it) } // 输出: // 1 // 2 // 3 // 4 // 5
let numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Integer"), 1, 2, 3, 4, 5)) // 打印数组中的每个元素 numbers.forEach((it) => { $console.log(it) }) // 输出: // 1 // 2 // 3 // 4 // 5
local numbers = _objectWrappers:wrap(_arrays:arrayOf(_plugins:loadClass("java.lang.Integer"), 1, 2, 3, 4, 5)) -- 打印数组中的每个元素 numbers:forEach(function(it) _console:log(it) end) -- 输出: -- 1 -- 2 -- 3 -- 4 -- 5
<?php $numbers = $objectWrappers->wrap($arrays->arrayOf($plugins->loadClass("java.lang.Long"), 1, 2, 3, 4, 5)); // 打印数组中的每个元素 $numbers->forEach(function ($it) use ($console) { $console->log($it); }); // 输出: // 1 // 2 // 3 // 4 // 5
numbers = _objectWrappers.wrap(_arrays.arrayOf(_plugins.loadClass("java.lang.Long"), 1, 2, 3, 4, 5)) # 打印数组中的每个元素 numbers.forEach(lambda it: _console.log(it)) # 输出: # 1 # 2 # 3 # 4 # 5
# encoding: utf-8 numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Long"), 1, 2, 3, 4, 5)) # 打印数组中的每个元素 numbers.forEach { |it| $console.log(it) } # 输出: # 1 # 2 # 3 # 4 # 5
Last modified: 05 September 2025