2 ms·
Yea I would prefer to use Emacs but I don't get access to that all the time. Thus my returns don't always get highlighted so it's as if I am using a basic text
by dangoldin 18y ago
Yea I would prefer to use Emacs but I don't get access to that all the time. Thus my returns don't always get highlighted so it's as if I am using a basic text editor.
In addition, I tend to read code from the bottom up (literally), so I end up tracing that return value upwards through the code. Also, having some simple branching let's me quickly identify what each block of code is doing.
Clearly there is not one way to do things and there are times where it's significantly easier to just return in the beginning but for more advanced cases I like having variables keep track.
Also, when there are many steps involved in the computation, it's easier to keep track of the individual pieces and then combine them at the very end than have that logic dispersed throughout the function.
I have also recently started favoring returning hashes so in case I ever need to add some additional results, backwards compatibility is preserved and I only need to work on one return statement.