2009/6/8 Luisgo <lgo...@gmail.com>: > > I've been a long time user of prototype and feel very comfortable in > most areas but this keeps coming up and I find it very annoying. > > I have a hash that, as the code executes is filled with numeric ID's > as hash variable names. I basically need it to end up sort of like > this: > > { > '4567':{}, > '9546':{}, > '6497':{}, > ... > } > > The problem is the IDs are passed as strings but casted as integers > when I do: > > myHash.set( idPassedInVariable, {} ); > > This causes the hash to be filled by undefined items where the > "missing" numeric IDs would be. In the example above I would end up > with 0 to 4566 being undefined and every space in between the rest of > the keys. > > Am I doing something wrong? Isn't there a way to make set pass the > string or is javascript simply going to force it to be a number? > > Thanks! > > > >
Using FireBug, I entered ... var a = {'4':{}, '8':{}, '12':{} } and then ... console.dir(a) and got ... >>> console.dir(a) 4 Object 8 Object 12 Object Which is exactly what I would expect. What if you cast the value as a string? myHash.set( String(idPassedInVariable), {} ); -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!" --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---