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

Allow looping over ranges #70

Merged
merged 8 commits into from
Nov 14, 2023

Conversation

bsilvia
Copy link
Contributor

@bsilvia bsilvia commented Nov 14, 2023

Fixes #60

Some design considerations:

  • It is not possible to specify negative numbers e.g. foreach (var i in -10..0) due to limitations with the implicit creation of Index from Range
  • The range is inclusive of the end so foreach(var i in 0..10) will yield [0, 1, ..., 10] which is equivalent to for(var i = 0; i <= 10; i++)
  • Since the end is inclusive, a range where the start and end are equal will yield 1 value e.g. foreach (var i in 0..0) will iterate once with i == 0

@ardalis ardalis merged commit aa1cc2a into ardalis:main Nov 14, 2023
@ardalis
Copy link
Owner

ardalis commented Nov 14, 2023

Thanks!

If you want, can you add example(s) to the Usage section in the README?

@bsilvia
Copy link
Contributor Author

bsilvia commented Nov 14, 2023

I'd be happy to add examples. Are you referring to #62?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow looping over ranges
2 participants