Skip to content

Instantly share code, notes, and snippets.

@jm-maniego
Last active May 1, 2016 18:49
Show Gist options
  • Save jm-maniego/63095554dde8d440af23db24c760004c to your computer and use it in GitHub Desktop.
Save jm-maniego/63095554dde8d440af23db24c760004c to your computer and use it in GitHub Desktop.
Yup, it's useless
class Array
def to_proc
proc {|x| inject(x) { |a, y| a.send(y) } }
end
end
class String
def to_proc
split(/\./).to_proc
end
end
strings_arr = ["AbcDef", "GhiJkl", "MnoPqr"]
strings_arr.map(&"underscore.upcase")
#=> ["ABC_DEF", "GHI_JKL", "MNO_PQR"]
strings_arr.map(&["underscore", "upcase"])
#=> ["ABC_DEF", "GHI_JKL", "MNO_PQR"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment