开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜