DEV Community

Discussion on: Be careful when memoizing booleans!

 
codeandclay profile image
Oliver

🤦 Of course. Thanks for the explanation. I'd convinced myself that it was returning the variable's value. Doh!

So, in my case I would use it like so:

  def happy?
    @happy = post_complete? if @happy.nil?
    @happy
  end