Got a question that the wiki doesn't answer? Ask on the forum (preferred), or join us on IRC.

BeastNode

CommandHelper/Staged/API/array index exists

From EngineHub.org Wiki
Jump to: navigation, search



Vital Info

Name array_index_exists
Returns boolean
Usages array, index
Throws CastException
Since 3.1.2
Restricted
No
Optimizations NO_SIDE_EFFECTS

Description

Checks to see if the specified array has an element at index

Usages

array_index_exists(array, index)

Examples (How do these work?)

Example 1

Demonstrates a true condition

Given the following code:

1   array_index_exists(array(0, 1, 2), 0)


The output would be:

:true

Example 2

Demonstrates a false condition

Given the following code:

1   array_index_exists(array(0, 1, 2), 3)


The output would be:

:false

Example 3

Demonstrates an associative array

Given the following code:

1   array_index_exists(array(a: 'A', b: 'B'), 'a')


The output would be:

:true

Example 4

Demonstrates an associative array

Given the following code:

1   array_index_exists(array(a: 'A', b: 'B'), 'c')


The output would be:

:false





Navigation menu