Last active
August 29, 2015 14:04
-
-
Save padde/cfa452b229c0cf3a124e to your computer and use it in GitHub Desktop.
Pass arguments to Ruby shortcut procs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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