# Really wierd behavior using object as a hashtable

**URL:** <https://forum.kirupa.com/t/really-wierd-behavior-using-object-as-a-hashtable/261853>\
**Category:** flash\
**Created:** [May 31, 2008, 8:37pm UTC](https://forum.kirupa.com/t/really-wierd-behavior-using-object-as-a-hashtable/261853 "2008-05-31T20:37:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![random0xff](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@random0xff](https://forum.kirupa.com/u/random0xff)\
**Post date:** [May 31, 2008, 8:37pm UTC](https://forum.kirupa.com/t/really-wierd-behavior-using-object-as-a-hashtable/261853/1 "2008-05-31T20:37:06Z")

</div>

If you paste this code into the constructor of a document class in Flash CS3 and put a breakpoint on the third line from the bottom you’ll see really weird things happening to the object o in the variables window:

```auto

var o:Object = {};
o["0"] = "Hello World";
o["1"] = "Hello World";
o["2"] = "Hello World";
o["3"] = "Hello World";
o["4"] = "Hello World";
o["5"] = "Hello World";
o["6"] = "Hello World";
o["7"] = "Hello World";
o["8"] = "Hello World";
o["9"] = "Hello World";
o[""] = "Hello World";
o["_"] = "Hello World";
o["!"] = "Hello World";
o["#"] = "Hello World";
o["$"] = "Hello World";
o["%"] = "Hello World";
o["'"] = "Hello World";
o["("] = "Hello World";
o[")"] = "Hello World";
o["*"] = "Hello World";
o["+"] = "Hello World";
o[","] = "Hello World";
o["-"] = "Hello World";
o["."] = "Hello World";
o["/"] = "Hello World";
o[":"] = "Hello World";
o[";"] = "Hello World";
o["="] = "Hello World";
o[">"] = "Hello World";
o["?"] = "Hello World";
o["@"] = "Hello World";
o["["] = "Hello World";
o["\\"] = "Hello World"; // Escape
o["]"] = "Hello World";
o["^"] = "Hello World";
o["`"] = "Hello World";
o["{"] = "Hello World";
o["|"] = "Hello World";
o["}"] = "Hello World";
o["~"] = "Hello World";

// Put breakpoint on next line and step through the next 3 lines
o["&lt;"] = "Hello World"; // All values starting from o[";"] are gone
o["&"] = "Hello World"; // All values starting from o["%"] are gone
o["\""] = "Hello World"; // All values starting from o["!"] are gone

```

Can anyone explain why this happens. If the code in the last three lines is not legal, why doesn’t the runtime throw an error? And is this per the ecma specifications, or documented elsewhere?

Thanks for any clarifications!

---

<div class="post-metadata">

**Author:** ![buginajar](https://avatars.discourse-cdn.com/v4/letter/b/f07891/32.png) [@buginajar](https://forum.kirupa.com/u/buginajar)\
**Post date:** [June 1, 2008, 2:57am UTC](https://forum.kirupa.com/t/really-wierd-behavior-using-object-as-a-hashtable/261853/2 "2008-06-01T02:57:49Z")

</div>

Not sure what is happening ( I didn’t try the code. );

Instead of an object, have you tried using a Dictionary object;

var o : Dictionary = new Dictionary();  
o[“1”] = “Whatever…”;

---

<div class="post-metadata">

**Author:** ![random0xff](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@random0xff](https://forum.kirupa.com/u/random0xff)\
**Post date:** [June 1, 2008, 1:41pm UTC](https://forum.kirupa.com/t/really-wierd-behavior-using-object-as-a-hashtable/261853/3 "2008-06-01T13:41:00Z")

</div>

Thanks for your reply. It does not matter if you use Dictionary or any other class. You see, it’s a language facility that allows you to add key/value pairs to any object. In fact, if you try it with a MovieClip, all the movieclip properties such as x, y, etc will disappear from the variables view during debugging when I step into the third line from the bottom. I don’t know about you, but I find that more than a little weird.

Please try the code, you can just copy paste it, it would only take 3 minutes and would really help me out a lot. Because I have no reference, there’s no documentation or any description of this as far as I know. I tried the ecma documents but that’s really hard to read.

What I’d like to know is:

1. Does the same thing happen to other people?
2. Is this considered normal?
3. If not, is it a bug, and is there a status on it?
4. If it’s by design, where can I read about it in specs or documentation?

Again, thanks for your reply, and please try the code, thanks!

---

<div class="post-metadata">

**Author:** ![Rezmason](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/rezmason/32/30447_2.png) [@Rezmason](https://forum.kirupa.com/u/Rezmason)\
**Post date:** [June 1, 2008, 5:46pm UTC](https://forum.kirupa.com/t/really-wierd-behavior-using-object-as-a-hashtable/261853/4 "2008-06-01T17:46:58Z")

</div>

I tried it with an untitled, unsaved document, and got the same results. There’s apparently no effect when not debugging. It’s probably a bug, and although it’s interesting, there’s not much we can conclude about Flash hashing from this.

If you’re interested in the way that Flash’s VM handles things like hash tables, you might try your luck perusing through the [Tamarin](http://www.mozilla.org/projects/tamarin/) source. But hashing is supposed to be one of those things that Flash encapsulates for you, so there’s not much documentation really.

---

<div class="post-metadata">

**Author:** ![random0xff](https://avatars.discourse-cdn.com/v4/letter/r/4af34b/32.png) [@random0xff](https://forum.kirupa.com/u/random0xff)\
**Post date:** [June 2, 2008, 10:42am UTC](https://forum.kirupa.com/t/really-wierd-behavior-using-object-as-a-hashtable/261853/5 "2008-06-02T10:42:58Z")

</div>

Hey thanks for trying. You are right, it’s actually only a bug in the Flash authoring environment.
