# ArrayEvery

Used to iterate over an array and test whether **every** item meets the test callback.

The function will be passed 3 arguments: the value, the index, and the array. You can alternatively pass a Java Predicate which will only receive the 1st arg. The function should return true if the item meets the test, and false otherwise.

**Note:** This operation is a short-circuit operation, meaning it will stop iterating as soon as it finds the first item that does not meet the test condition.

## Parallel Execution

If the `parallel` argument is set to true, and no `max_threads` are sent, the filter will be executed in parallel using a ForkJoinPool with parallel streams. If `max_threads` is specified, it will create a new ForkJoinPool with the specified number of threads to run the filter in parallel, and destroy it after the operation is complete. This allows for efficient processing of large arrays, especially when the test function is computationally expensive or the array is large.

## Method Signature

```
ArrayEvery(array=[array], callback=[function:Predicate], parallel=[boolean], maxThreads=[any], virtual=[boolean])
```

### Arguments

| Argument     | Type                 | Required | Description                                                                                                                                                                                                                                                                                     | Default |
| ------------ | -------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `array`      | `array`              | `true`   | The array to test against the callback.                                                                                                                                                                                                                                                         |         |
| `callback`   | `function:Predicate` | `true`   | The function to invoke for each item. The function will be passed 3 arguments: the value, the index, the array. You can alternatively pass a Java Predicate which will only receive the 1st arg.                                                                                                |         |
| `parallel`   | `boolean`            | `false`  | Whether to run the filter in parallel. Defaults to false. If true, the filter will be run in parallel using a ForkJoinPool.                                                                                                                                                                     | `false` |
| `maxThreads` | `any`                | `false`  | <p>The maximum number of threads to use when running the filter in parallel. If not passed it will use the default number of threads for the ForkJoinPool.<br>If parallel is false, this argument is ignored. If a boolean is provided it will be assigned to the virtual argument instead.</p> |         |
| `virtual`    | `boolean`            | `false`  | If true, the function will be invoked using virtual threads. Defaults to false. Ignored if parallel is false.                                                                                                                                                                                   | `false` |

## Examples

### Example for positive result

Checks whether all items in an array are greater than 2 and outputs true because all of them fulfill the requirement.

[Run Example](https://try.boxlang.io/?code=eJxLLCpKrFSwVYhW4OI00eHiNAViMyA254q15iovyixJ9S8tKSgt0VBIBKl0LUstqoSydRQ0FBzzKhXKEnNKUxU0FWztFKq5OItSS0qL8qCCdgpG1ly1QDlNay4AGTodsA%3D%3D)

```java
array = [ 
	4,
	5,
	6,
	7
];
writeOutput( arrayEvery( array, ( Any value ) => {
	return value > 2;
} ) );

```

Result: true

### Example for negative result

Checks whether all items in an array are greater than 2 and outputs false because some of them do not fulfill the requirement.

[Run Example](https://try.boxlang.io/?code=eJxLLCpKrFSwVYhW4OI01OHiNAJiYyA24Yq15iovyixJ9S8tKSgt0VBIBKl0LUstqoSydRQ0FBzzKhXKEnNKUxU0FWztFKq5OItSS0qL8qCCdgpG1ly1QDlNay4AFRodpA%3D%3D)

```java
array = [ 
	1,
	2,
	3,
	4
];
writeOutput( arrayEvery( array, ( Any value ) => {
	return value > 2;
} ) );

```

Result: false

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJxljkELgjAYhs%2F7fsWLJ4WhFXpJFDxUENSlY4QMWpfmlOmCEf73JhgYXR8envdtXC2MEQ4FriD2JsbO1WmHLYK9EfoZcE%2BqwwTSFbGR%2FzoXKxfGZv1vHNt%2BqWSpV%2BiWk1CqbtXd7zbzhVi%2BpHEhQlTaoZOmbzUiFCV8z8jBGj3TeGqVhX%2BU08gxGCs5MkQ53W3Thfi2PUCS4CFUL%2BkDrGE7rw%3D%3D)

```java
my_array = [ 
	{
		NAME : "Frank",
		AGE : 40
	},
	{
		NAME : "Sue",
		AGE : 21
	},
	{
		NAME : "Jose",
		AGE : 54
	}
];
all_old = my_array.every( ( Any person ) => {
	return person.AGE >= 40;
}, true, 5 );
dump( all_old );
 // false

```

## Related

* [ArrayAppend](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayappend)
* [ArrayAvg](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayavg)
* [ArrayChunk](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraychunk)
* [ArrayClear](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayclear)
* [ArrayContains](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraycontains)
* [ArrayContainsNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraycontainsnocase)
* [ArrayDelete](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraydelete)
* [ArrayDeleteAt](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraydeleteat)
* [ArrayDeleteNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraydeletenocase)
* [ArrayEach](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayeach)
* [ArrayFilter](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfilter)
* [ArrayFind](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfind)
* [ArrayFindAll](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfindall)
* [ArrayFindAllNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfindallnocase)
* [ArrayFindFirst](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfindfirst)
* [ArrayFindNoCase](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfindnocase)
* [ArrayFirst](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayfirst)
* [ArrayFlatMap](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayflatmap)
* [ArrayFlatten](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayflatten)
* [ArrayGetMetadata](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraygetmetadata)
* [ArrayGroupBy](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraygroupby)
* [ArrayIndexExists](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayindexexists)
* [ArrayInsertAt](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayinsertat)
* [ArrayIsDefined](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayisdefined)
* [ArrayLast](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraylast)
* [ArrayMap](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraymap)
* [ArrayMax](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraymax)
* [ArrayMedian](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraymedian)
* [ArrayMerge](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraymerge)
* [ArrayMid](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraymid)
* [ArrayMin](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraymin)
* [ArrayNew](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraynew)
* [ArrayNone](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraynone)
* [ArrayPop](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraypop)
* [ArrayPrepend](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayprepend)
* [ArrayPush](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraypush)
* [ArrayRange](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayrange)
* [ArrayReduce](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayreduce)
* [ArrayReduceRight](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayreduceright)
* [ArrayReject](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayreject)
* [ArrayResize](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayresize)
* [ArrayReverse](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayreverse)
* [ArraySet](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayset)
* [ArrayShift](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayshift)
* [ArraySlice](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayslice)
* [ArraySome](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraysome)
* [ArraySort](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraysort)
* [ArraySplice](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraysplice)
* [ArraySum](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraysum)
* [ArraySwap](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayswap)
* [ArrayToList](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraytolist)
* [ArrayToStruct](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraytostruct)
* [ArrayTranspose](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arraytranspose)
* [ArrayUnique](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayunique)
* [ArrayUnshift](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayunshift)
* [ArrayZip](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayzip)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayevery.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
