Created
May 31, 2012 04:49
-
-
Save yuroyoro/2841131 to your computer and use it in GitHub Desktop.
Onject#tapeval is Object#tap with Object#instance_eval
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
| # | |
| # tapeval is Object#tap with instance_eval | |
| # => "hoge".tapeval{puts self * 2; gsub!(/ge/,'oooooo!!!') } | |
| # hogehoge | |
| # "hooooooo!!!" | |
| # | |
| class Object | |
| def tapeval(&block) | |
| instance_eval(&block) if block_given? | |
| self | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment