Created
August 27, 2012 08:31
-
-
Save epramono/3486686 to your computer and use it in GitHub Desktop.
TryRuby Level 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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