all
val numbers = arrayOf(2, 4, 6, 8, 10)
val names = arrayOf("Alice", "Bob", "Charlie")
// 检查 numbers 数组中的所有元素是否都是偶数
val allEven = numbers.all { it % 2 == 0 }
_console.log("numbers 数组中的所有元素都是偶数吗:", allEven) // 输出:true
// 检查 names 数组中的所有元素是否都包含字母 "a"
val allContainA = names.all { it.contains("a") }
_console.log("names 数组中的所有元素都包含字母 \"a\" 吗:", allContainA) // 输出:false
def numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Integer"), 2, 4, 6, 8, 10))
def names = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.String"), "Alice", "Bob", "Charlie"))
// 检查 numbers 数组中的所有元素是否都是偶数
def allEven = numbers.all { it % 2 == 0 }
$console.log("numbers 数组中的所有元素都是偶数吗:", allEven) // 输出:true
// 检查 names 数组中的所有元素是否都包含字母 "a"
def allContainA = names.all { $objectWrappers.wrap(it).contains((char) 'a') }
$console.log("names 数组中的所有元素都包含字母 \"a\" 吗:", allContainA) // 输出:false
let numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Integer"), 2, 4, 6, 8, 10))
let names = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.String"), "Alice", "Bob", "Charlie"))
// 检查 numbers 数组中的所有元素是否都是偶数
let allEven = numbers.all((it) => {
return it % 2 == 0
})
$console.log("numbers 数组中的所有元素都是偶数吗:", allEven) // 输出:true
// 检查 names 数组中的所有元素是否都包含字母 "a"
let allContainA = names.all((it) => {
return $objectWrappers.wrap(it).contains("a")
})
$console.log("names 数组中的所有元素都包含字母 \"a\" 吗:", allContainA) // 输出:false
local numbers = _objectWrappers:wrap(_arrays:arrayOf(_plugins:loadClass("java.lang.Integer"), 2, 4, 6, 8, 10))
local names = _objectWrappers:wrap(_arrays:arrayOf(_plugins:loadClass("java.lang.String"), "Alice", "Bob", "Charlie"))
-- 检查 numbers 数组中的所有元素是否都是偶数
local allEven = numbers:all(function(it)
return it % 2 == 0
end)
_console:log("numbers 数组中的所有元素都是偶数吗:", allEven) -- 输出:true
-- 检查 names 数组中的所有元素是否都包含字母 "a"
local allContainA = names:all(function(it)
return _objectWrappers:wrap(it):contains(string.byte("a"))
end)
_console:log("names 数组中的所有元素都包含字母 \"a\" 吗:", allContainA) -- 输出:false
<?php
$numbers = $objectWrappers->wrap($arrays->arrayOf($plugins->loadClass("java.lang.Long"), 2, 4, 6, 8, 10));
$names = $objectWrappers->wrap($arrays->arrayOf($plugins->loadClass("java.lang.String"), "Alice", "Bob", "Charlie"));
// 检查 numbers 数组中的所有元素是否都是偶数
$allEven = $numbers->all(function ($it) {
return $it % 2 == 0;
});
$console->log("numbers 数组中的所有元素都是偶数吗:", $allEven); // 输出:true
// 检查 names 数组中的所有元素是否都包含字母 "a"
$allContainA = $names->all(function ($it) use ($objectWrappers) {
return $objectWrappers->wrap($it)->contains("a");
});
$console->log("names 数组中的所有元素都包含字母 \"a\" 吗:", $allContainA); // 输出:false
numbers = _objectWrappers.wrap(_arrays.arrayOf(_plugins.loadClass("java.lang.Long"), 2, 4, 6, 8, 10))
names = _objectWrappers.wrap(_arrays.arrayOf(_plugins.loadClass("java.lang.String"), "Alice", "Bob", "Charlie"))
# 检查 numbers 数组中的所有元素是否都是偶数
allEven = numbers.all(lambda it: it % 2 == 0)
_console.log("numbers 数组中的所有元素都是偶数吗:", allEven) # 输出:true
# 检查 names 数组中的所有元素是否都包含字母 "a"
allContainA = names.all(lambda it: _objectWrappers.wrap(it).contains('a'))
_console.log("names 数组中的所有元素都包含字母 \"a\" 吗:", allContainA) # 输出:false
# encoding: utf-8
numbers = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.Long"), 2, 4, 6, 8, 10))
names = $objectWrappers.wrap($arrays.arrayOf($plugins.loadClass("java.lang.String"), "Alice", "Bob", "Charlie"))
# 检查 numbers 数组中的所有元素是否都是偶数
allEven = numbers.all { |it| it % 2 == 0 }
$console.log("numbers 数组中的所有元素都是偶数吗:", allEven) # 输出:true
# 检查 names 数组中的所有元素是否都包含字母 "a"
allContainA = names.all { |it| $objectWrappers.wrap(it).contains(Java::JavaLang::Character.new('a')) }
$console.log("names 数组中的所有元素都包含字母 \"a\" 吗:", allContainA) # 输出:false
Last modified: 08 August 2025