Make foreach element optional
Imperatorn
johan_forsberg_86 at hotmail.com
Tue Mar 16 16:29:45 UTC 2021
On Tuesday, 16 March 2021 at 13:52:29 UTC, Per Nordlöw wrote:
> On Tuesday, 16 March 2021 at 13:31:34 UTC, Imperatorn wrote:
>> foreach(0..n) could work. Why though.
>
> When performing a side-effect n times.
Then why not just do:
auto times(alias F, T)(T number)
{
return number.iota.each!(_ => F());
}
void f()
{
writeln("hi");
}
n.times!(f);
?
More information about the Digitalmars-d-learn
mailing list