Skip to content

Instantly share code, notes, and snippets.

@keijiro
Created October 19, 2011 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save keijiro/1298141 to your computer and use it in GitHub Desktop.
Save keijiro/1298141 to your computer and use it in GitHub Desktop.
Associative array in JavaScript (UnityScript)
#pragma strict
class StrIntArray {
private var table = new Hashtable();
function Set(key1 : String, key2 : int, value : String) {
table[key1 + "/" + key2] = value;
}
function Get(key1 : String, key2 : int) : String {
return table[key1 + "/" + key2] as String;
}
}
var a = new StrIntArray();
a.Set("foo", 1, "bar");
Debug.Log(a.Get("foo", 1));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment