3 ms·
Re (1, assignment of conditional), I tend to avoid this construction, though I don't stress about it too much in code review. It's just fairly easy to lose trac
by rezonant 2y ago
Re (1, assignment of conditional), I tend to avoid this construction, though I don't stress about it too much in code review. It's just fairly easy to lose track of the fact that an assignment is occuring except in the most simplest of cases. I also extend this to implicit return -- like with explicit self I used to be militant that explicit return was always clearer and safer. However, in an "idiomatic" short method I think it's fine, you must understand and be cognizant of Ruby's return semantics no matter what. However, once it becomes clear that there is a chance someone will lose sight of the fact that we're doing a bigass return statement in this huge block of conditionals, I employ explicit return.
I'm also a huge fan of using early return to handle edge cases and exceptional cases. This is something a lot of developers disagree with me on, but I've never been sufficiently convinced to avoid it.