0050 Cache_falsy_value

Cache false/nil

||= is the most common way of caching. Except that it doesn’t handle false and nil! defined? can be a solution by checking whether the variable is defined. ⚠️ Be sure to take into account when the parser defines the variable! (cf local_variable)

0050-cache_falsy_value_1.png

Links to Ruby documentation for ||= and defined?.