mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Clarify behavior of generator (functions)
Patch provided by an anonymous user. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@345249 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
c44311cab0
commit
482bc1d69c
1 changed files with 3 additions and 3 deletions
|
@ -98,7 +98,7 @@ Single digit odd numbers from xrange(): 1 3 5 7 9
|
|||
<sect2 xml:id="language.generators.object">
|
||||
<title><classname>Generator</classname> objects</title>
|
||||
<para>
|
||||
When a generator function is called for the first time, an object of the
|
||||
When a generator function is called, a new object of the
|
||||
internal <classname>Generator</classname> class is returned. This object
|
||||
implements the <classname>Iterator</classname> interface in much the same
|
||||
way as a forward-only iterator object would, and provides methods that can
|
||||
|
@ -119,13 +119,13 @@ Single digit odd numbers from xrange(): 1 3 5 7 9
|
|||
<para>
|
||||
When a generator function is called, it returns an object that can be
|
||||
iterated over. When you iterate over that object (for instance, via a
|
||||
&foreach; loop), PHP will call the generator function each time it needs a
|
||||
&foreach; loop), PHP will call the object's iteration methods each time it needs a
|
||||
value, then saves the state of the generator when the generator yields a
|
||||
value so that it can be resumed when the next value is required.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Once there are no more values to be yielded, then the generator function
|
||||
Once there are no more values to be yielded, then the generator
|
||||
can simply exit, and the calling code continues just as if an array has run
|
||||
out of values.
|
||||
</para>
|
||||
|
|
Loading…
Reference in a new issue