Skip to content

Instantly share code, notes, and snippets.

@Sixeight
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sixeight/10959997 to your computer and use it in GitHub Desktop.
Save Sixeight/10959997 to your computer and use it in GitHub Desktop.
こういうの欲しい
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