Returns true
if the provided predicate function returns true
for at least one element in a collection, false
otherwise.
Use Iterable.any()
to test if any elements in the collection return true
based on fn
.
代码实现
bool some<T>(Iterable<T> itr, bool Function(T) fn) {
return itr.any(fn);
}
使用样例
some([0, 1, 2, 0], (x) => x >= 2); // true