Skip to content

Instantly share code, notes, and snippets.

@sk187
Created March 26, 2015 15:36
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 sk187/4bab7e902b726c0e21e9 to your computer and use it in GitHub Desktop.
Save sk187/4bab7e902b726c0e21e9 to your computer and use it in GitHub Desktop.
Passing Ruby Methods as a Proc
#You can pass Ruby methods like a Proc
#Non Proc Example
numbers = [1,2,3,4,5]
string_numbers = numbers.map{ |number| number.to_s}
#Returns
["1","2","3","4","5"]
#Proc Example
numbers = [1,2,3,4,5]
string_numbers = numbers.map(&:to_s)
#Returns
["1","2","3","4","5"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment