Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Proc Composability
class Proc
def self.compose(f, g)
lambda { |*args| f[g[*args]] }
end
def *(g)
Proc.compose(self, g.to_proc)
end
def |(g)
Proc.compose(g.to_proc, self)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.