Last active
August 29, 2015 13:59
-
-
Save Sixeight/10959997 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
module BindTap | |
def btap(&block) | |
self.instance_eval(&block) | |
self | |
end | |
end | |
Object.include BindTap | |
hash = {a: 1, b: 2, c: 3} | |
b = hash.dup.tap do |hash| | |
hash.delete :a | |
hash.delete :b | |
end | |
p hash #=> {:a=>1, :b=>2, :c=>3} | |
p b #=> {:c=>3} | |
c = hash.dup.btap do | |
delete :a | |
delete :b | |
end | |
p hash #=> {:a=>1, :b=>2, :c=>3} | |
p c #=> {:c=>3} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment