diff options
author | Gautam Kotian <gautam.kotian@gmail.com> | 2015-10-13 18:17:11 +0200 |
---|---|---|
committer | Gautam Kotian <gautam.kotian@gmail.com> | 2015-10-13 18:17:11 +0200 |
commit | 4be1044a64e7ac1000a458087ee9131a9999d05f (patch) | |
tree | 841433ae9d7f14f9ee7c33630823275aa5878409 /d.html.markdown | |
parent | 064b82eab443fa1bc8c1dd0b061bedbc04b60e66 (diff) |
Improve code comments
Diffstat (limited to 'd.html.markdown')
-rw-r--r-- | d.html.markdown | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/d.html.markdown b/d.html.markdown index d56e08a6..88a83e41 100644 --- a/d.html.markdown +++ b/d.html.markdown @@ -38,9 +38,10 @@ void main() { writeln(i); } - auto n = 1; // use auto for type inferred variables + // 'auto' can be used for inferring types. + auto n = 1; - // Numeric literals can use _ as a digit seperator for clarity + // Numeric literals can use '_' as a digit separator for clarity. while(n < 10_000) { n += n; } @@ -49,13 +50,15 @@ void main() { n -= (n / 2); } while(n > 0); - // For and while are nice, but in D-land we prefer foreach - // The .. creates a continuous range, excluding the end + // For and while are nice, but in D-land we prefer 'foreach' loops. + // The '..' creates a continuous range, including the first value + // but excluding the last. foreach(i; 1..1_000_000) { if(n % 2 == 0) writeln(i); } + // There's also 'foreach_reverse' when you want to loop backwards. foreach_reverse(i; 1..int.max) { if(n % 2 == 1) { writeln(i); @@ -80,7 +83,7 @@ struct LinkedList(T) { class BinTree(T) { T data = null; - // If there is only one template parameter, we can omit parens + // If there is only one template parameter, we can omit the parentheses BinTree!T left; BinTree!T right; } |