Created
July 6, 2012 10:09
-
-
Save oriolgual/3059354 to your computer and use it in GitHub Desktop.
to tap or not to tap?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do_it(ids) | |
contacts = contact_finder(ids) | |
contacts = contacts.my_nice_scope if should_apply_nice_scope? | |
contacts | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def do_it(ids) | |
contact_finder(ids).tap do |contacts| | |
return contacts.my_nice_scope if should_apply_nice_scope? | |
end | |
end |
I like the no_tap version, because it communicates everything at a glance. You're fetching contacts, then maybe filtering them or not, and returning them. The second version is way more complicated to understand at a glance (and has the same LOC).
+1 to the no_tap version
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is returning inside tap really that bad? :P