Skip to main content
このトピックへの返信は締め切られました。

返信数 1

Participant
November 15, 2012

Since the index value of an element must be less than the length of the array this function ist worth nothing!

BKBK
Community Expert
Community Expert
November 15, 2012

I disagree. It can be that:

1) You are in a position in the code where you don't know the length of the array;

2)  You know the array's length is 3, for example, and you know the values of arr[1] and arr[3]. It is still possible that arr[2] doesn't exist.

Participant
November 15, 2012

Sure, in this specific way it would work.

Well, the description says "True, if the array element is defined (exists)". So in my opinion it has to determine, if an index exists, no matter if the index is bigger than the length of the array. The isDefined function does the same. It checks the existance of an variable.

Let's say you loop through an array of users and several users are redundant. Now you would like to determine, if the next user is unequal to the current user. At the last index this funktion would through an error, which is pretty uncomfortable.

The only way to make this function work without errors, would be to check first the current index with the length of an array and after that to use the ArrayIsDefined Function.