Skip to content

Commit 36b6e43

Browse files
peterjaapOskarStark
authored andcommitted
Fix example with iterable
1 parent a423250 commit 36b6e43

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

components/console/helpers/progressbar.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,17 @@ which starts, advances and finishes the progress bar automatically::
110110

111111
$progressBar = new ProgressBar($output);
112112

113-
// $iterable can be for example an array ([1, 2, 3, ...]) or a generator
114-
// $iterable = function () { yield 1; yield 2; ... };
113+
// $iterable can be for example an array ([1, 2, 3, ...])
114+
$iterable = [1, 2];
115115
foreach ($progressBar->iterate($iterable) as $value) {
116116
// ... do some work
117117
}
118+
119+
// or a generator
120+
function iterable() { yield 1; yield 2; ... };
121+
foreach ($progressBar->iterate(iterable()) as $value) {
122+
// ... do some work
123+
}
118124

119125
If ``$iterable = [1, 2]``, the previous code will output the following:
120126

0 commit comments

Comments
 (0)