Created
October 15, 2009 14:50
-
-
Save jasonroelofs/210999 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Normal | |
def method | |
ret_val = "something" | |
do_this_thing if ret_val == "something" | |
ret_val | |
end | |
# Or with #tap | |
def method | |
ret_val = "something" | |
ret_val.tap {|v| do_this_thing if v } # still returns ret_val | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment