Re: Let range() return a generator?

From: Date: Sat, 18 Mar 2017 01:14:42 +0000
Subject: Re: Let range() return a generator?
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-98580@lists.php.net to get a copy of this message
On Fri, Mar 17, 2017 at 10:46 AM, Sara Golemon <pollita@php.net> wrote: > On Fri, Mar 17, 2017 at 1:40 AM, Niklas Keller <me@kelunik.com> wrote: >> Yes, that's a BC break. Instead of changing it, there could be a new >> function. But as it can be simply built in userland, I don't see much >> reason to have it in core. >> > 100% agreed. This is a 3 line function and doing it in userland means > you can use it in 5.5 or later. > > function range($low, $high) { > for ($i = $low; $i <= $high; ++$i) { yield $i; } > } > In fact, here: This is how easy that is. https://packagist.org/packages/phplang/generator

« previous php.internals (#98580) next »