Skip to content

Instantly share code, notes, and snippets.

@wolframkriesing
Created December 21, 2012 15:22
Show Gist options
  • Save wolframkriesing/4353437 to your computer and use it in GitHub Desktop.
Save wolframkriesing/4353437 to your computer and use it in GitHub Desktop.
var dict = new Dictionary;
dict[runTests] = true;
var isFirstRun = true;
for (var key in dict) {
trace('key = ' + key);
if (isFirstRun) {
dict[this] = true;
isFirstRun = false;
}
delete dict[key];
}
trace("dict[this] = " + dict[this]);
trace("dict[runTests] = " + dict[runTests]);
trace('======');
var dict = new Dictionary;
dict[this] = true;
var isFirstRun = true;
for (var key in dict) {
trace('key = ' + key);
if (isFirstRun) {
dict[runTests] = true;
isFirstRun = false;
}
delete dict[key];
}
trace("dict[this] = " + dict[this]);
trace("dict[runTests] = " + dict[runTests]);
/* outputs
key = function Function() {}
dict[this] = true
dict[runTests] = undefined
======
key = [object DictionaryTests]
key = function Function() {}
dict[this] = undefined
dict[runTests] = undefined
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment