Last active
March 28, 2020 20:04
-
-
Save TheGag96/f80a5a75a55122b54f1790ed41031046 to your computer and use it in GitHub Desktop.
Static foreach example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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