RaycastAll grid, null reference error?

Trying to raycast with a grid and return gameobjects hit, this is the jist of it, getting null reference, object not set to an instance of an object:

GOScript.CastRays (System.Object graphxcords, System.Object graphycords) (at Assets/GOScript.js:112)

which basically points to last line in code

arrayOfHitGos : GameObject[];
    
    
    
function Start(){
    //do some stuff & start SomeCoroutine();
}
    
    
SomeCoroutine(){
    for(var y in ycords){
         for(var x in xcords){
               returnToEqualThisVar=CastRays(x,y);
         }
    }
}
    
    
    
function CastRays(graphxcords, graphycords){
    var hit : RaycastHit[];
    var ray : Ray = camera.ViewportPointToRay (Vector3 (graphxcords,graphycords,0));
    if (Physics.RaycastAll (ray, 1<<4)){
    	arrayOfHitGos = new GameObject [hit.Length];
    }
}

Physics.RaycastAll() returns an array of RaycastHit structures, not a boolean. So you code should be something like:

hit = Physics.RaycastAll(ray, 1<<4));
if (hit.Length > 0) {
    arrayOfHitGos = new GameObject [hit.Length];
}