When not to use Memoization in Ruby on Rails

Memoization is a wonderful concept in programming world. It helps in writing clean code which execute faster.

Example:

In above code, slow_method will cache perform_slow_method in @result variable, therefore perform_slow_method will execute only once.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store