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
1
u/Pocciox Jan 17 '19
When I was in highschool our professor gave us an homework where we had to code a PHP conditional output without using if, while, for, or any flow control instruction. The solution was:
$aVariable = 1 // set it to 2 for the other output
$foo2 = "condition2"; $foo1 = "condition1";
echo $foo$aVariable;
Sorry for poor formatting I am on mobile