Skip to content

Instantly share code, notes, and snippets.

@padde
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save padde/cfa452b229c0cf3a124e to your computer and use it in GitHub Desktop.
Save padde/cfa452b229c0cf3a124e to your computer and use it in GitHub Desktop.
Pass arguments to Ruby shortcut procs
class Array
def to_proc
->(obj) { obj.public_send *self }
end
end
input = <<EOS
foo,bar,baz
hello,world
1,2,3
EOS
input.lines
.map(&:chomp)
.map(&[:split, ','])
.map(&[:join, '+'])
.join('--')
# => "foo+bar+baz--hello+world--1+2+3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment