Allow discards in foreach #8948
Replies: 3 comments 3 replies
-
Why not do: for(int i = 0; i < 100; ++i)
{
// ...
} PS. Or: 100.Repeat(() =>
{
// ...
});
public static void Repeat(this int This, Action action) { ... } |
Beta Was this translation helpful? Give feedback.
2 replies
-
While it's still an extremely low priority item, I would rather see something like: do(100) // any size integer expression goes inside the parens
{
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
See: #7888 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I was writing some code that randomized some input for testing. I wanted to test it a bunch of times, so I threw it in a loop. Much to my surprise, this doesn't work:
I think it would be nice to allow discards here. You can of course still use
var _
, but then_
becomes a variable and you effectively can't use discards within that block. Note, this silly thing works:I recognize this is an incredibly niche use case, and only really applies to this one scenario.
Beta Was this translation helpful? Give feedback.
All reactions