Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Determines whether a particular array element is valid.
Syntax
public boolean exists(int index)
Run On
Called
Parameters
- index
Type: int
The array element to test.
Return Value
Type: boolean
true if the array element that is pointed to by the index is valid; otherwise, false.
Examples
The following example uses the exists method to test whether various elements in an array are valid.
{
array a = new array(types::Integer);
a.value(1, 23);
print a.value(1);
pause;
if (a.exists(7)) // No, only element 1 is initialized
{
print a.value(7);
}
else
{
print "Value does not exist";
}
pause;
//Array positions 2 to 9 padded with default values
a.value(10, 55);
if (a.exists(7)) // Yes, elements 1..10 now initialized
{
print a.value(7);
}
else
{
print "Value does not exist";
}
pause;
}