Ray cast downward for ground collision

I would like to cast a ray downward to see if the ray collides with the ground. Here is what I have so far.

function Update{
var downDirection : Vector3 = Vector3(0,-10,0);

Debug.DrawRay (transform.position, Vector3.downDirection, Color.green);
}

How would I go about actually detecting a collision and returning a boolean as true if such collision were detected while still drawing the ray.

var hit : RaycastHit;
var dist : float;
var dir : Vector3;

function Update(){
     dist = 10;
     dir = Vector3(0,-1,0);

     //edit: to draw ray also//
     Debug.DrawRay(transform.position,dir*dist,Color.green);
     //end edit//

     if(Physics.Raycast(transform.position,dir,hit,dist)){
          //the ray collided with something, you can interact
          // with the hit object now by using hit.collider.gameObject
     }
     else{
          //nothing was below your gameObject within 10m.
     }

}

not working, always working

else{
//nothing was below your gameObject within 10m.
}
else part only

@JuanseCoello

//for C# version of suggested code

//I’m pretty sure that this var hit : RaycastHit;

//could be written as this RaycastHit hit;

//so following that logic

 RaycastHit hit;
 float dist;
 Vector3 dir;

//Otherwise everything else should probably remain
//the same