Skip to content

Instantly share code, notes, and snippets.

@yuroyoro
Created May 31, 2012 04:49
Show Gist options
  • Select an option

  • Save yuroyoro/2841131 to your computer and use it in GitHub Desktop.

Select an option

Save yuroyoro/2841131 to your computer and use it in GitHub Desktop.
Onject#tapeval is Object#tap with Object#instance_eval
#
# 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