Skip to content

Instantly share code, notes, and snippets.

Created November 29, 2013 22:54
What would you like to do?
Simple composition of ruby lambdas.
class Proc
def *(f)
->(*args) { self.(f.(*args)) }
plus2 = ->(n) { n+2 }
plus3 = ->(n) { n+3 }
plus5 = plus2 * plus3
plus5.(5) # returns 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment