3 ms·
If you don't care about side effects: C: int foo = bar ? 2 : 4; Go: foo := map[bool]int{true:2, false:4}[bar] Python had a similar trick before 2.5
by saturncoleus 10y ago
If you don't care about side effects:
C:
int foo = bar ? 2 : 4;
Go:
foo := map[bool]int{true:2, false:4}[bar]
Python had a similar trick before 2.5 added ternary conditionals.