Yes. I think where it's unclear to me is commands like next item
(ioIterator).
For example:
$c := new collection
` add some items to the collection
next item($c)
You can't use 'next item' with $c, $c is a collection handle, not an
iterator. Think of a collection handle as an array, and an iterator
as a pointer to an array.
After doing something like the above, is this still valid?
$value := $c{"some_key"}
You can't do what you did earlier, but if $c is a collection handle
you can always do what you are doing here. If $c is an iterator, on
the other hand, the collection is essentially read only.
From page 196, "Iterator Validity":
"Warning: If you delete or add an item in a collection, any iterators
for that collection
will no longer be valid. Thus you should not attempt to delete or add
items while
iterating over a collection."
I'm trying to get a sense of when to use an iterator versus a handle.
Ordinarily you never need to use an iterator. Iterators are only for
traversing the items of a collection, analogous to 'for ($i; 1; size
of array($arr))'. AS the documentation suggests, if you just need to
iterate over a collection, you don't need iterators at all, you use
'for each':
for each($c; $key) // see page 195
// do something with $c{$key}
Regards,
Aparajita
www.aparajitaworld.com
"If you dare to fail, you are bound to succeed."
- Sri Chinmoy | www.srichinmoylibrary.com
_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/