For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
any
def any[IterableType: Iterable](iterable: IterableType) -> Bool where conforms_to(IterableType.IteratorType[iterable].Element, Boolable & Deinitable)
Checks whether any element in the iterable is truthy.
Checks elements in order and stops at the first truthy element. An empty
iterable returns False.
For example:
print(any([0, 0, 5])) # True
print(any([0, 0, 0])) # False
Parameters:
- IterableType (
Iterable): The type of the iterable. Its elements must conform toBoolableandDeinitable.
Args:
- iterable (
IterableType): The iterable to check.
Returns:
Bool: True if any element is truthy, False otherwise.
def any(var iterable: T) -> Bool where conforms_to(T.IteratorOwnedType.Element, Boolable & Deinitable)
Checks if any element in the iterable is truthy, consuming the iterable.
Args:
- iterable (
T): The iterable to consume and check.
Returns:
Bool: True if any element in the iterable is truthy, False otherwise.