Last active
December 11, 2015 19:48
-
-
Save rodrigopinto/4650576 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
| class User | |
| attr_accessor :first_name, :last_name | |
| end | |
| # sem o método tap | |
| user = User.new | |
| user.first_name = "Rodrigo" | |
| user.last_name = "Pinto" | |
| puts user.first_name # => Rodrigo | |
| puts user.last_name # => Pinto | |
| # com o método tap | |
| user_using_tap = User.new.tap do |u| | |
| u.first_name = "Rodrigo 2" | |
| u.last_name = "Pinto 2" | |
| end | |
| puts user_using_tap.first_name # => Rodrigo 2 | |
| puts user_using_tap.last_name # => Pinto 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment