Unity GameObjects can have materials. Some of them can have multiple materials, which are an array of materials. Sometimes you want change a material in an array of materials on the fly. This is how you do that in script.

Set the materials:

public Material BaseTerrainGrass;  
public Material BaseTerrainRock;  
public Material BaseTerrainSlate;  
public Material BaseTerrainSand;  
public Material BaseTerrainSnow;  
public GameObject BaseTerrainObject;  

Then you go into your Inspector and set all of your materials on your component. That will look like this:

Then you set those materials on start:

    void Start () {
        BaseTerrainObject.GetComponent<Renderer> ().materials [0] = BaseTerrainGrass;
        BaseTerrainObject.GetComponent<Renderer> ().materials [1] = BaseTerrainRock;
        BaseTerrainObject.GetComponent<Renderer> ().materials [2] = BaseTerrainSlate;
        BaseTerrainObject.GetComponent<Renderer> ().materials [3] = BaseTerrainSand;
        BaseTerrainObject.GetComponent<Renderer> ().materials [4] = BaseTerrainSnow;

Once you go into your game and click start, you should see this on your terrain object:

To change them on the fly via script, you need to fill a variable with your materials array. I'm calling that terrainMats and then finding the materials array within the Renderer component.

Then you take that array and change one of the materials in it. Then you set that array as the new materials array. Yeah it's kind of a circular process.

var terrainMats = BaseTerrainObject.GetComponent<Renderer> ().materials;  
terrainMats[0] = BaseTerrainSnow;  
BaseTerrainObject.GetComponent<Renderer> ().materials = terrainMats;