Skip to content

Fix example with iterable #13027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions components/console/helpers/progressbar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,17 @@ which starts, advances and finishes the progress bar automatically::

$progressBar = new ProgressBar($output);

// $iterable can be for example an array ([1, 2, 3, ...]) or a generator
// $iterable = function () { yield 1; yield 2; ... };
// $iterable can be for example an array ([1, 2, 3, ...])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it could be reworded now to something like // $iterable can be an array

$iterable = [1, 2];
foreach ($progressBar->iterate($iterable) as $value) {
// ... do some work
}

// or a generator
function iterable() { yield 1; yield 2; ... };
foreach ($progressBar->iterate(iterable()) as $value) {
// ... do some work
}

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

Expand Down