Skip to content
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

Expanded examples for foreach alias, loops and keywords #473

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PalmEmanuel
Copy link

PR Summary

Added a few examples in AboutLoopsAndPipelines regarding the foreach cmdlet alias vs loop and how the break, continue and return keywords affect pipelines vs standard loops.

Fixes #404

Context

No particular context or background for the PR, see issue for linked discussions and examples of topics.

Changes

Added a new Context to AboutLoopsAndPipelines called "Loops and Keywords" with 5 new It assertions to clarify some important things regarding pipeline loops vs keyword/standard loops.

  • Loops and Keywords
    • It is possible to break a standard loop - Shows break in a normal loop
    • It is possible to skip iterations of a standard loop - Shows continue in a normal loop
    • It is possible to return a value from a standard loop - Shows return in a normal loop
    • It has the same name but not the same behaviour - Shows break with a pipeline foreach alias
    • It returns differently when used in a pipeline - Shows return with a pipeline ForEach-Object

Checklist

  • Pull Request has a meaningful title.
  • Summarised changes.
  • Pull Request is ready to merge & is not WIP.
  • Added tests / only testable interactively.
    • Make sure you add a new test if old tests do not effectively test the code changed.
  • Added documentation / opened issue to track adding documentation at a later date.

@PalmEmanuel
Copy link
Author

PalmEmanuel commented Oct 5, 2022

I had trouble coming up with very clear examples for all topics in #404 without making them very bloated or advanced, let me know if there's something that doesn't feel right!

@vexx32 vexx32 added the hacktoberfest-accepted PRs that have been accepted for Hacktoberfest label Oct 28, 2022
@vexx32
Copy link
Owner

vexx32 commented Oct 28, 2022

Thanks for the PR! I haven't had the time to give this a thorough review yet, but I plan to shortly. 💖

Sorry for the delay in response. 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hacktoberfest-accepted PRs that have been accepted for Hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expand AboutLoopsAndPipelines to cover edge cases / misunderstandings
2 participants