Skip to content

Instantly share code, notes, and snippets.

@TheGag96
Last active March 28, 2020 20:04
Show Gist options
  • Save TheGag96/f80a5a75a55122b54f1790ed41031046 to your computer and use it in GitHub Desktop.
Save TheGag96/f80a5a75a55122b54f1790ed41031046 to your computer and use it in GitHub Desktop.
Static foreach example
void func(size_t size)() {
static foreach (p; 0..size) {
perform_some_action(p);
}
}
void perform_some_action(size_t p) {
import std.stdio : writeln;
writeln(p);
}
void main() {
func!7();
}
/*
Output:
0
1
2
3
4
5
6
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment