Skip to content

Instantly share code, notes, and snippets.

@raganwald
Created July 21, 2015 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save raganwald/6e1fd8344cb62a2afe9c to your computer and use it in GitHub Desktop.
Save raganwald/6e1fd8344cb62a2afe9c to your computer and use it in GitHub Desktop.
# See https://twitter.com/fogus/status/623312803345117184
def meth a, b, c
[yield(a), yield(b), yield(c)]
end
meth(1, 2, 3) { |x| x * x }
# => [1, 4, 9]
arr = [1962, 6, 14, lambda { |x| x.to_s }]
meth(*arr[0..-2], &arr.last)
# => ["1962", "6", "14"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment