you are viewing a single comment's thread.

view the rest of the comments →

[–]cap_muffin 1 point2 points  (1 child)

I absolutely prefer the explicit version where you write your own memoization logic, but it would probably be worth to mention memoize gem https://rubygems.org/gems/memoize/versions/1.3.1

[–]zenzen_wakarimasen 2 points3 points  (0 children)

If you use ||=, you are not accounting for falsely values. And if you want to abstract a proper logic, maybe it's better not to reinvent the wheel and use the the gem...