06.10.25.md (732B)
1 06/10/25 2 ======== 3 4 Compound operators 5 ------------------ 6 7 ``` 8 x += 3 9 x *= 3 10 x -= 3 11 x /= 3 12 ``` 13 14 Post increment 15 -------------- 16 17 ``` 18 x++ 19 x-- 20 ``` 21 22 When you say `y = x++` y is equ to x and x is equ to x + 1 23 24 Pre increment 25 ------------- 26 27 ``` 28 --x 29 ++x 30 ``` 31 32 When you say `y = ++x` y is equ to x + 1 and x is equ to x + 1 33 34 Branching 35 --------- 36 Standard conditional 37 38 ``` 39 if (x) { 40 f(); 41 } 42 else if (y) { 43 g(x); 44 } 45 else { 46 h(x); 47 } 48 ``` 49 50 Switch statement 51 52 ``` 53 switch (x) { 54 case 1: 55 f(x); 56 break; 57 case 2: 58 g(x); 59 break; 60 default: 61 h(x); 62 break; 63 } 64 ``` 65 66 Ternary operator 67 68 ``` 69 val = (x) ? f(x) : g(x); 70 ``` 71 72 Comments 73 -------- 74 Multi line comments `/* stuff */` 75 Single line comments `// stuff`