Ruby on Rails Tuesday, September 1, 2015

As you read through Ruby code, you may see this construction:

@foo ||= some_expensive_operation(parameters)

That's known as memoizing (take a memo) or memorizing (or memorising if you're in England).

What it does is take the existing value if the expensive operation has already run once, or return and store for later the result of the expensive operation. It's a one-liner in-memory cache.

Walter

> On Sep 1, 2015, at 10:41 AM, Elizabeth McGurty <emcgurty2@gmail.com> wrote:
>
> And I am also super confused as to the notion of 'memorising'. What does that mean? Kids memorise the alphabet and times tables, what does that metaphor mean in terms of Ruby and Ruby on Rails? Memorising is a process of repeatedly iterating through a series that must eventually be held in one's memory. Does Rails have some neural process of educating itself in neural memorising?
> Liz

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/FF9741F3-0177-423F-A2EB-16800107EE68%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment