Last week I was reading through a method a colleague wrote and it looked something like this:
Now this really confused me. Why would you ever be so verbose and use a method like defined? when you could simply just use ruby memoization, and write something like this:
After some digging and refactoring i discovered something interesting that I never thought of before. What happens when @hello = false
Basically with ruby's memoization when it sees the @hello = false it assumes that is undefined and tries to rewrite it.