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
)