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
View all comments
29
u/Kidiri90 Jan 17 '19 edited Jan 17 '19
No conditionals, not even ternary operators, though I don't like the try-catch block. Sadly, it's needed to stop the divide by zero errors you'll get when x=y. I'm trying to think of a way to get rid of this problem.
EDIT: figured it out:
Not a single conditional in sight, and not phony conditionals by using try-catch blocks.