Why freeze memoization?

I was wondering what was the reasoning behind freezing the Memoizable
return values?

Thanks

On Aug 25, 3:32 am, trans [email protected] wrote:

I was wondering what was the reasoning behind freezing the Memoizable
return values?

to protect you from stuff like

foo = bar.memoized_method
foo.gsub!(…)
#do something with foo

If you did this and foo wasn’t frozen then you’d alter what
memoized_method returned for all future calls - probably not what was
intended

Fred

On Aug 25, 2:55 am, Frederick C. [email protected]
wrote:

to protect you from stuff like

foo = bar.memoized_method
foo.gsub!(…)
#do something with foo

If you did this and foo wasn’t frozen then you’d alter what
memoized_method returned for all future calls - probably not what was
intended

Makes sense. Thanks.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs