mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Fix variable name typo in dlang examples.
This commit is contained in:
parent
ae654256e5
commit
1391eed837
@ -53,15 +53,15 @@ void main() {
|
|||||||
// For and while are nice, but in D-land we prefer 'foreach' loops.
|
// For and while are nice, but in D-land we prefer 'foreach' loops.
|
||||||
// The '..' creates a continuous range, including the first value
|
// The '..' creates a continuous range, including the first value
|
||||||
// but excluding the last.
|
// but excluding the last.
|
||||||
foreach(i; 1..1_000_000) {
|
foreach(n; 1..1_000_000) {
|
||||||
if(n % 2 == 0)
|
if(n % 2 == 0)
|
||||||
writeln(i);
|
writeln(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
// There's also 'foreach_reverse' when you want to loop backwards.
|
// There's also 'foreach_reverse' when you want to loop backwards.
|
||||||
foreach_reverse(i; 1..int.max) {
|
foreach_reverse(n; 1..int.max) {
|
||||||
if(n % 2 == 1) {
|
if(n % 2 == 1) {
|
||||||
writeln(i);
|
writeln(n);
|
||||||
} else {
|
} else {
|
||||||
writeln("No!");
|
writeln("No!");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user