4/22/2025 at 7:27:18 PM
Since using `def` to create a method returns a symbol with the method name, you can do something like this too: memoize def expensive_calculation(arg)
@calculation_count += 1
arg * 2
end, ttl: 10, max_size: 2
memoize def nil_returning_method
@calculation_count += 1
nil
end
by madsohm
4/23/2025 at 2:04:38 AM
This is why I love working with Ruby!by hp_hovercraft84