4 ms·
Thank for posting this! I recently had quite a few discussions about this topic with people who insist to _always_ use if/elseif/elsif/... constructs in such si
by yoodenvranx 8y ago
Thank for posting this! I recently had quite a few discussions about this topic with people who insist to _always_ use if/elseif/elsif/... constructs in such situations. I tried to argue that in most situations a "if (a) {return}; if (b) {return}; do_c()" construction is much easier to understand but I had only little success convincing them.
- Flow 8y agoI always say that if you know the answer, why convolute the code? Just return the damn answer and we're done here. I see these early returns as a list of assumptions. It helps making them nicely lined up, with perhaps some comments before each, and an empty line between them. And then when you get below to the, now non-nested, code that actually does some work you have a smaller mental burden needed to understand what is actually done.