Ruby on Rails Friday, January 10, 2014

On Fri, Jan 10, 2014 at 9:55 AM, Dave Castellano <lists@ruby-forum.com> wrote:

> The code below works perfectly but is so repetitive I feel there must be
> a standard way to refactor it in this situation.

It looks like the general pattern is to check if a given thing is
present, and if so, do a bunch of things, all of which are included in
the previous bunch (except of course for the first). So, maybe
instead of an else-chain, just make them all independent ifs, and have
them do ONLY what is not included in the next one.

-Dave

--
Dave Aronson, the T. Rex of Codosaurus LLC (codosaur.us),
freelance software developer, and creator of these sites:
PullRequestRoulette.com, blog.codosaur.us, & Dare2XL.com.

--
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/CAHxKQih7Xg%3DLoAM8a0xLHVLi%2B%3DcHX9VjfJPhbVd7DxQ%3DcJc2JA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment