Skip to content

Instantly share code, notes, and snippets.

Created June 7, 2014 21:06
Show Gist options
  • Save anonymous/79a57517f53e275bb1b3 to your computer and use it in GitHub Desktop.
Save anonymous/79a57517f53e275bb1b3 to your computer and use it in GitHub Desktop.
result = my_arrai.each_with_object({}) do |word, transformed|
transformed[word] = word.capitalize
end
puts result
##### OR #####
def transform(my_arrai)
my_arrai.each_with_object({}) do |word, transformed|
transformed[word] = word.capitalize
end
end
my_arrai = %w[mama died today or was it yesterday]
puts transform(my_arrai)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment