- Home /
How to write Multidimensional Hashes?
I code in Unity's Javascript-like language.
I'm wondering if I can use multidimensional hashes and what the syntax would look like?
Essentially, I just want to create a hash that represents a relationship between two groups of objects, like so:
link{A}{alpha} = 1;
link{B}{beta} = 1;
link{C}{gamma} = 1;
...
cheers
$$anonymous$$y apologies to everyone who took the time to answer this question or comment. $$anonymous$$y behavior was vile. I've had nothing but good instructive interaction with people here. I sincerely regret my bizarre outbursts.
Answer by skovacs1 · Jul 14, 2010 at 07:44 PM
I've never heard of a multidimensional hash before, but it seems like a multidimensional associative array. I googled javascript multidimensional hash and the first hit and the related comment in the second hit seem like what you're asking for, are they?
Unity js arrays can be indexed by strings or numbers just like in regular js, so you'd get code that looks like:
var hash = {};
hash["foo"] = {};
hash["foo"]["bar"] = {};
hash["foo"]["bar"]["bash"] = 1;
As noted in the first link that I posted, you should check for null values when indexing a multidimensional associative array.
You've never heard of a multidimensional hash? That just seems like an obliquely "stupified" comment. Not particularly what I'm looding for, but thank's for the pointers.
I'm a LOT more insterested in iff CombineChildren works in an Editing setting.
I'll note not- given the hysterical nature of responses to this question.
I'm not sure what you don't understand about skovacs1 reply. He's suggesting that the exact behavior you want can be accomplished with a dictionary which in turn contains dictionaries. It's not a multi-dimentional hash, so his answer to your question is spot-on. I also fail to see what CombineChildren in an Editing setting has to do with your original question.