Created
April 2, 2020 13:17
-
-
Save AJFaraday/93420a1e3169391dc832af3e2b142b90 to your computer and use it in GitHub Desktop.
Overuse of tap? - which is better?
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
class SomeClass | |
def do_things | |
thing_one | |
thing_two | |
thing_three | |
end | |
def thing_one | |
do_something | |
end | |
def thing_two | |
do_something | |
end | |
def thing_three | |
do_something | |
end | |
end | |
SomeClass.new.do_things |
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
class SomeClass | |
def do_things | |
thing_one.thing_two.thing_three | |
end | |
def thing_one | |
tap do | |
do_something | |
end | |
end | |
def thing_two | |
tap do | |
do_something | |
end | |
end | |
def thing_three | |
tap do | |
do_something | |
end | |
end | |
end | |
SomeClass.new.do_things |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment