On Mo, 2017-07-03 at 17:32 +0200, Niklas Keller wrote: > > That distinction is the reason why next() and valid() are different > > methods in iterators. > > Not really, Iterator::next() returns void, so could as well return > bool.
Well, that story is a bit longer and I cut it short. Let's assume we remove valid and use next's return value. Then we don't know if the first element exists or not, as next is only called after the first iteration. An alternative might be using only current() but then we need a special, magic, return value to mark the end oder references. Both are bad. johannes -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php