1
0
mirror of https://github.com/php/doc-en.git synced 2026-03-23 23:32:18 +01:00

Better wording for generators (#1854)

This commit is contained in:
Kamil Tekiela
2024-10-17 01:48:30 +02:00
committed by GitHub
parent 216c5dc1ef
commit 08e58ace7e

View File

@@ -15,16 +15,17 @@
</para>
<para>
A generator allows you to write code that uses &foreach; to iterate over a
set of data without needing to build an array in memory, which may cause
you to exceed a memory limit, or require a considerable amount of
processing time to generate. Instead, you can write a generator function,
A generator offers a convenient way to provide data to &foreach; loops without
having to build an array in memory ahead of time, which may cause the program
to exceed a memory limit or require a considerable amount of
processing time to generate. Instead, a generator function can be used,
which is the same as a normal
<link linkend="functions.user-defined">function</link>, except that instead
of
<link linkend="functions.returning-values">return</link>ing once, a
generator can &yield; as many times as it needs to in order to provide the
values to be iterated over.
Like with iterators, random data access is not possible.
</para>
<para>