scripting Impact explosion

I have a fireball type projectile and there is an explosion prefab, but how do i script it to explode upon impact with a collider?

Attach this script to the fireball and add the explosion prefab to it.

public explosion : Transform;
function OnCollisionEnter(collision : Collision) {
    Instantiate (explosion, transform.position, transform.rotation);
    Destroy (this);
}