Ruby: Tricking Your Mind
Sometimes when programming, we trick our minds into thinking something is somethat it clearly isn t. One really good case of this is Ruby ||=
. We like to think of it as set something if it doesn’t have a value - which is certainly not what it means (and not what it should mean).
Slow your mind down and consider this gotcha that will getcha every time:
And its cousin:
Try tracking that one down! Being explicit can be really helpful, as well as not letting your mind hold onto too many shortcuts for common patterns.