Skip to content

Instantly share code, notes, and snippets.

@intentionally-left-nil
Created June 1, 2017 22:46
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 intentionally-left-nil/220627cd96875eddf680513c7204f96c to your computer and use it in GitHub Desktop.
Save intentionally-left-nil/220627cd96875eddf680513c7204f96c to your computer and use it in GitHub Desktop.
recursion breakout
def first_initials(names)
names.reduce({}) do |letters, name|
first_letter = name[0]
if letters[first_letter] == nil
letters[first_letter] = 1
else
letters[first_letter] += 1
end
letters
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment