M8Test Help

maxOf

val numbers = arrayOf(10, 20, 30, 5, 15) // 查找数组中的最大值 val maxValue = numbers.maxOf { it } // 输出:最大值: 30 _console.log("最大值: ", maxValue)
def numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Integer"), 10, 20, 30, 5, 15)) // 查找数组中的最大值 def maxValue = numbers.maxOf { it } // 输出:最大值: 30 $console.log("最大值: ", maxValue)
let numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Integer"), 10, 20, 30, 5, 15)) // 查找数组中的最大值 let maxValue = numbers.maxOf(it => it) // 输出:最大值: 30 $console.log("最大值: ", maxValue)
local numbers = _objectWrappers:wrap(_arrays:arrayOf(_plugins:loadClass("java.lang.Integer"), 10, 20, 30, 5, 15)) -- 查找数组中的最大值 local maxValue = numbers:maxOf(function(it) return it end) -- 输出:最大值: 30 _console:log("最大值: ", maxValue)
<?php $numbers = $objectWrappers->wrap($arrays->arrayOf($plugins->loadClass("java.lang.Long"), 10, 20, 30, 5, 15)); // 查找数组中的最大值 $maxValue = $numbers->maxOf(function ($it) { return $it; }); // 输出:最大值: 30 $console->log("最大值: ", $maxValue);
numbers = _objectWrappers.wrap(_arrays.arrayOf(_plugins.loadClass("java.lang.Long"), 10, 20, 30, 5, 15)) # 查找数组中的最大值 maxValue = numbers.maxOf(lambda it: it) # 输出:最大值: 30 _console.log("最大值: ", maxValue)
# encoding: utf-8 numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Long"), 10, 20, 30, 5, 15)) # 查找数组中的最大值 maxValue = numbers.maxOf { |it| it } # 输出:最大值: 30 $console.log("最大值: ", maxValue)
Last modified: 09 September 2025