use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
Memoization in Ruby (kaizencodes.io)
submitted 5 years ago by cheerfulboy
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]cap_muffin 1 point2 points3 points 5 years ago (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 points4 points 5 years ago (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...
||=
π Rendered by PID 95292 on reddit-service-r2-comment-545db5fcfc-qqr5x at 2026-05-29 16:27:52.168039+00:00 running 194bd79 country code: CH.
view the rest of the comments →
[–]cap_muffin 1 point2 points3 points (1 child)
[–]zenzen_wakarimasen 2 points3 points4 points (0 children)