Skip to content

Instantly share code, notes, and snippets.

@hamidp
Created July 17, 2011 21:34
Show Gist options
  • Save hamidp/1088091 to your computer and use it in GitHub Desktop.
Save hamidp/1088091 to your computer and use it in GitHub Desktop.
Ruby Pipeline
def method_missing(sym, *args)
if(sym.to_s == "pl")
send(args[0], self)
end
end
def square ar
ar.map! { |i| i * i }
end
def halve ar
ar.map! { |i| i / 2 }
end
(([1,2,3,4,5,6,7,8,9,10].pl :square
).pl :halve
).pl :puts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment