Hello, On Mon, Feb 8, 2010 at 3:31 PM, mathieu.suen <mathieu.s...@easyflirt.com> wrote: > Hi, > > Whenever you implement the Iterator interface the key method should only > return a scalar. > Is there any particular reason for this restriction. > IMHO I don't see any.
The iterator interface was implemented on top of an API that explicitly requested integers/strings as keys. It hasn't been changed since. > I also don't see why you can't index an array with object but it smells > something going wrong underneath. Historic reasons. Nothing would technically prevent objects from being accepted as keys. Also, note that the SPLObjectStorage class can be used for that task precisely. It is designed to work as an Object Map/Set. > > Thanks > > - Mathieu Suen > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Etienne Kneuss http://www.colder.ch -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php