Two Ruby Memoization Patterns

Two main memoization patterns I’ve seen are the following Example #1 is shorter, however if you stare at it hard enough you’ll realize if @the_thing is supposed to be false or a falsy value then it would never be memoized. Example #2 of checking if the variable has been defined is a more sure method … Read more

Ruby Nullish States

Just want to point out a great post by Joyce Echessa talking about the differences between all the nullish state methods for Ruby: Nil? Empty? Present? Blank? #nil? #empty? #blank? #present? 5 false NoMethodError false true “” false true true false ” ” false false true false “\t\n” false false true false [] false true … Read more

Explain Rails Active Record Query

You can output the raw query for an Active Record Query by tagging .explain at the end. Very useful for complex queries where it’s hard to understand what is happening under the hood 🤯. You can read the docs for more info.