Skip to content

Instantly share code, notes, and snippets.

@karthikselva
Created March 14, 2013 11:42
Show Gist options
  • Select an option

  • Save karthikselva/5160723 to your computer and use it in GitHub Desktop.

Select an option

Save karthikselva/5160723 to your computer and use it in GitHub Desktop.
I feel geekish ( readability is absent for sure ) when I use map with an symbol proc for an array :D
# Convert all elements in an array from integer to string
[1,2,3].map(&:to_s)
# Test output:
# ===========
#
# 1.8.7-p358 :001 > a = [1,2,3]
#
# => [1, 2, 3]
#
# 1.8.7-p358 :002 > a.map(&:to_s)
#
# => ["1", "2", "3"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment