Skip to content

Instantly share code, notes, and snippets.

@epramono
Created August 27, 2012 08:31
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 epramono/3486686 to your computer and use it in GitHub Desktop.
Save epramono/3486686 to your computer and use it in GitHub Desktop.
TryRuby Level 4
# Ruby style
books.values.each { |rate| ratings[rate] += 1 }
# Java style
for (Object rate : books.getValues()) {
Integer count = ratings.get (rate);
if (count != null) ratings.put (rate, new Integer(count.intValue() + 1))
else ratings.put (rate, new Integer(1));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment