Reply to Re: objects of MyClass in array?

Your name:

Reply:


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]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация