davearonson
Joined 1/25/2017
davearonson said almost 8 years ago on Random Ruby Tips and Tricks :

Be careful when using ||= with Boolean values.  ||= will set something not only if it's nil, but also if it's literally false, i.e., the one object named false, of class FalseClass.  In short it will set it if it's "falsey".

That part also reminded me of some strange code I encountered recently: "if status == status = 1 || status = 2 || status = 3".  See http://blog.codosaur.us/2016/11/x-x-wtf.html for a writeup of what that was probably meant to do, and what it really did.


davearonson said over 7 years ago on Routing Partials :

Just wondering about the use of .map there.  Does the mapper actually somehow use the result of each call, so that it becomes important to use .map, or is the important part more of a side-effect, so that .each would do?  If the latter, I think that would be clearer as it wouldn't raise this question, in the minds of those of us who tend to overthink things.  :-)