Skip to content

Instantly share code, notes, and snippets.

@pjb3
Created June 11, 2012 22:51
Show Gist options
  • Save pjb3/2913229 to your computer and use it in GitHub Desktop.
Save pjb3/2913229 to your computer and use it in GitHub Desktop.
Tap that object
# To tap
def activate_person(person_id)
Person.find(person_id).tap do |person|
person.activate!
end
end
# or not to tap
def activate_person(person_id)
person = Person.find(person_id)
person.activate!
person
end
# that is the question
@jc00ke
Copy link

jc00ke commented Jun 12, 2012

@glv @pjb3 A few months back @brixen saw me using #tap and lamented on how it's not ideal because it creates a new scope when a perfectly suitable one already exists. From what I remember he said it's not worth extending the stack for no good reason. Why make the VM do more work when the context is already set up already? @brixen, did I get that right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment