2 ms·
I do 99% of my work in a terminal and usually over ssh. that's why I use Emacs. Since you use a single return statement I'm assuming you keep track of the valu
by cstejerean 18y ago
I do 99% of my work in a terminal and usually over ssh. that's why I use Emacs.
Since you use a single return statement I'm assuming you keep track of the value to return by assigning it to a variable. How is keeping track of multiple assignments to the variable you will return easier than keeping track of multiple return statements? I've always found it easier to keep track of return statements since they're highlighted.
- dangoldin 18y agoYea 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.