Created
June 18, 2014 01:37
-
-
Save busches/7e4c8889427247b2fd33 to your computer and use it in GitHub Desktop.
This file contains 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
<cfscript> | |
data = ['a','b','a']; | |
counts = {}; | |
for (datum in data) { | |
if (!structKeyExists(counts, datum)) { | |
counts[datum] = 0; | |
} | |
counts[datum] = counts[datum]++; | |
} | |
writeDump(counts); // all zeros | |
counts = {}; | |
for (datum in data) { | |
if (!structKeyExists(counts, datum)) { | |
counts[datum] = 0; | |
} | |
counts[datum] = counts[datum] + 1; | |
} | |
writeDump(counts); // correct counts | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment