Basic Lines of Code in D
- Types
int,long,double
- Variables
int n = 42;auto n = 42;immutable int n = 42;string[] words;Matrix!double mat;ContactInfo[string] contactInfoForID;
- Functions
int multiply(int a, int b) { return a * b; }void print(ContactInfo a) { ... }string concat(string a, string b) { return ...; }
- Loops
foreach (i; 1..11) { ... }foreach (i; 0..words.length) { ... }foreach (i; [5, 7, 11, 13]) { ... }foreach (word; words) { ... }
Note
In Dintand42are 32 bits wide, not 64 bits.