|
Posted by Steve on 01/08/08 00:04
"Rik Wasmus" <luiheidsgoeroe@hotmail.com> wrote in message
news:op.t4k2u0075bnjuv@metallium.lan...
> On Tue, 08 Jan 2008 00:31:57 +0100, Steve <no.one@example.com> wrote:
>> "devloop" <andrea2004@gmx.de> wrote in message
>> news:a21e6087-932a-4683-95d0-3d1d65d7288e@s19g2000prg.googlegroups.com...
>> Thank you soooo much! That΄s it! I would have cost me years to find
>> that as in JAVA you may write this or leave it!
>>
>> Do I have to add any include line to use iterator class or
>> collections? Do they exist in php?
>>
>> ===========
>>
>> no.
>
> Yes, Iterators exist, as the are an interface for a class.
should have been more specific. 'no' was to the first question...does he
have to do anything special. do they exist? clearly. the only time he has to
mess with it though is if he wants to customize a class of his own so that
it is directly enumerable.
>> there is very little strong typing in php
>
> Which has to do with?
usually people customize a class to be enumerable is to get performance
benefits in storing a specific type rather than a variant, default
collection. that's what i meant. the second most common is functional
clarity for the caller.
>> and an array has the
>> enumerable interface. anything you put in an array can be iterated with
>> foreach
>
> Yes, however, creating an object as an ArrayObject/implementing
> ArrayIterator, and private variables, will give you the possibility for
> type hinting:
true...but, i don't have that ide if 'intellisense' is what you mean. :)
as for the code below, MyParticularObject can 'hint' a function param type
anywhere...even a proc function. so, i'm not sure what you mean.
>
> class MyCollection implements ArrayIterator{
> ...
> private $values = array();
> public function add(MyParticularObject $value){
> $this->values[] = $value;
> }
> }
[Back to original message]
|