Skip to content

Instantly share code, notes, and snippets.

@petrachi
Created September 26, 2014 13:31
Show Gist options
  • Save petrachi/637f9367404708ec341a to your computer and use it in GitHub Desktop.
Save petrachi/637f9367404708ec341a to your computer and use it in GitHub Desktop.
pipable
A = ->(s){ s << "a" }
B = ->(s){ s << "b" }
C = ->(s){ s << "c" }
str = ""
class Object
PIPED = ->(*args, arg){ arg.is_a?(Proc) ? arg[PIPED[*args]] : arg }
def | *args
PIPED.curry[self, *args]
end
end
puts str | A | B | C
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment