# ArraySome

Used to iterate over an array and test whether **ANY** items meet 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 meets 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. Please note that this may not be the most efficient way to iterate, as it will create a new ForkJoinPool for each invocation of the BIF. You may want to consider using a shared ForkJoinPool for better performance.

## Method Signature

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

### Arguments

| Argument     | Type                 | Required | Description                                                                                                                                                                                                                                                                                     | Default |
| ------------ | -------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
| `array`      | `array`              | `true`   | The array to reduce                                                                                                                                                                                                                                                                             |         |
| `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 thread. Defaults to false. Ignored if parallel is false.                                                                                                                                                                                    | `false` |

## Examples

### Simple Example

[Run Example](https://try.boxlang.io/?code=eJxFjjFrAkEQhWv3V7xMIXsguT5iRNImMZAihaQYzKgL3u4yO4uI5L%2Fn7pTYPN684vumbfGiwibgCFblsxvzNRTDAhs3Ic75KDTrWw5R7lfHcZ%2FGxlnDNhm577lrW7yxbQ8oqROnUupxAI3Qz37y%2BOfP4LGKZ%2By0BkODxTMubqJiVeN1fCzGauUr2MGDmNDM3e8QveVDQzRcBe6kwWRdLVfz8DfrEjQYCU%2Bg90QNpiB0w3NSgJOoYJdq%2FHkYuX8nvVIz)

```java
// Create an array
arrayList = [
	"apple",
	"pineapple",
	"mango",
	"apricot"
];
// Match some
result = arraySome( arrayList, ( Any fruit ) => {
	return fruit.startsWith( "a" );
} );
// Print result
writeOutput( (result ? "Some" : "No") & " matches  were found!" );

```

Result: Some matches were found!

### Member Function Example

[Run Example](https://try.boxlang.io/?code=eJxFjr2KAkEQhGPnKeo6kF043PxE5bj0foQLLjgMGm11wJ0ZenoQEd%2Fd3VU0Kaoq%2BKqaBh8qbAIOYFU%2BuUE%2FfTbM8O9GxCkdhF47l3yQZ2o57OLgOKlfRyO3mrqmwRfbeo8cW3EquRx60AM66fsKFd7DCVst3lBjNsfZjVSsaLiVEwmb%2FOdtX4GYUE%2FdpZeOvlQfDDewO6o3%2BSmWinXM%2B9oC9NuNEN5A35FqjEFo%2B1OSgaOoYBtL2LwM3CtS9U8f)

```java
// Create an array
arrayList = [
	"apple",
	"pineapple",
	"mango",
	"apricot"
];
// Match some
result = arrayList.some( ( Any fruit ) => {
	return fruit.endsWith( "a" );
} );
// Print result
writeOutput( (result ? "Some" : "No") & " matches  were found!" );

```

Result: No matches were found!

### Additional Examples

[Run Example](https://try.boxlang.io/?code=eJydjrEKgzAYhGfzFEcmBanUVVLwGTqWDlF%2FqZTEEg2tlL57k0hah05djvuP475f0702Ri4QOIElXPLcaRO03fhu4yloz9m5Yp1VtxQ6rmQVu8jpOCrau0XpM398GzlS1HrBMJPKV9c9VuPayCAOeLLE0GyNDi0IAQeu2Muvr7wPwyVFAUWqIYPe6nYeRh1fKN0Lkbubwht%2Fwa8%2F4aVP3u3AWrY%3D)

```java
newArray = [ 
	"a",
	"b",
	"c",
	"b",
	"d",
	"b",
	"e",
	"f"
];
dump( newArray );
hasSome1 = arraySome( newArray, ( Any item, Any idx, Any arr ) => {
	return item == "b";
} );
dump( hasSome1 );
// member function
hasSome2 = newArray.some( ( Any item, Any idx, Any arr ) => {
	return item == "k";
} );
dump( hasSome2 );

```

## 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)
* [ArrayEvery](https://boxlang.ortusbooks.com/boxlang-language/reference/built-in-functions/array/arrayevery)
* [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)
* [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/arraysome.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.
