5 ms·
What's wrong with coding bug fixes as "if" statements?
by fezzl 16y ago
What's wrong with coding bug fixes as "if" statements?
- hackerblues 16y agoOriginal: def double(x): return x+3 BUG REPORT: double(4) returns 7 instead of 8. Fixed: def double(x): if x == 4: return 8 else: return x+3
- praptak 16y agoI think that's indeed what OP meant, but there's also: def abs(x): return x ... where adding the 'if' seems appropriate :)