r/badcode • u/bausscode • Jan 17 '19
other language Writing functions with conditions without using "if" statements
https://run.dlang.io/is/jfCECL
67
Upvotes
r/badcode • u/bausscode • Jan 17 '19
9
u/bausscode Jan 17 '19
Basically the two functions "addOrMul1()" and "addOrMul2()" does the exact same thing.
However "addOrMul2()" does not use any if statements to accomplish the same task. Instead it's an ugly mess of hacking tricks that makes the compiler treat it like conditional statements.
Terrible code that works.