2D Arrays of GameObjects

I'm trying to make a 2D array of cubes for easy referencing, and I'm using this as my starting place. I tried testing it with integers and it works just fine, but whenever I try to use GameObjects I get a runtime error.

I added this to the MultiDim.cs:

public static GameObject[,] GameObjectArray (int a, int b) {
        return new GameObject[a,b];

And then I have this in my main tester:

var cube : GameObject;
var x = 2;
var y = 2;
var tiles;

function Start()
    var i;
    var j;

    tiles = MultiDim.GameObjectArray(x,y);

    for(i = 0; i < y; i++)
        for(j = 0; j < x; j++)
            Instantiate(cube, Vector3(j, 0, i), transform.rotation);
                    tiles[j,i] = cube;

But I always get the runtime error: MissingFieldException: Field 'UnityEngine.GameObject[,].' not found;

Well I changed the line: `tiles = MultiDim.GameObjectArray(x,y);` to

var tiles = MultiDim.GameObjectArray(x,y);

and it worked? I guess I am not allowed to have global variables when using this?

You can't use dynamic typing:

var tiles;

The point of using MultiDim is that it types the variable correctly using type inference:

var tiles = MultiDim.GameObjectArray(x,y);

You can resize the array later if necessary by using MultiDim again.

In Unity 3.2 you can just do

var tiles : GameObject[,];

and you don't need MultiDim anymore.