开发者

What are the drawbacks of using ||= syntax to perform memoization

开发者 https://www.devze.com 2023-03-31 09:32 出处:网络
I have noticed several individuals comment on how their use of ||= to perform memoization was \'sloppy\' but they did it anyway \'because they w开发者_JAVA技巧ere in a rush\'.

I have noticed several individuals comment on how their use of ||= to perform memoization was 'sloppy' but they did it anyway 'because they w开发者_JAVA技巧ere in a rush'.

I also found ActiveSupport::Memoizable.

I'm lead to conclude that ||= has drawbacks.

So what are they?


Well, the biggest reason I'm aware of is that you can't memoize nil or false values like that.


I suggest reading this:
When to use memoization in Ruby on Rails

And this:
http://www.railway.at/articles/2008/09/20/a-guide-to-memoization/

0

精彩评论

暂无评论...
验证码 换一张
取 消