Determining if an array is empty

Jan Schenkel janschenkel at yahoo.com
Tue Jun 29 15:10:10 EDT 2004


--- Gregory Lypny <gregory.lypny at videotron.ca> wrote:
> Hello everyone,
> 
> Suppose I have an array named thisArray and I want
> to know if it is 
> empty, that is, whether it has any elements.  I find
> that
> 
> 	"if thisArray is empty" returns true even if it is
> not
> 
> 	but
> 
> 	"if keys(thisArray) is empty" gives me the right
> answer
> 
> Am I correct in using the latter?
> 
> 	Greg
> 

Hi Greg,

You are correct ; it's one of the peculiarities of
Revolution arrays that you need to check the keys of
the array to determine if an array has any elements.
It is incidentally also the only way to check if a
variable is an array or not : if the keys is empty,
it's not an array.

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


		
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 


More information about the use-livecode mailing list