A Silly simple question about scope

I am trying to add a LineRenderer to an object during runtime using script, so I can visualize a vector. I can add the component just fine, but I can’t seem to access sub components from the component after creating it and I can’t figure out why.

private var line:Component;

function Start () {
	line = gameObject.AddComponent(LineRenderer);	

function Update () {

With this code I get the error “‘SetPosition’ is not a member of ‘UnityEngine.Component’”

What am I doing wrong? It must be a simple mistake.

This occurs because AddComponent returns Component, it does not return an object of type LineRenderer. To get access to the methods you want, you have to declare the line as a LineRenderer in the top there, instead of Component:

private var line:LineRenderer;

The types should match just fine, because LineRenderer inherits from Renderer, which in turn inherits from Component, so a LineRenderer is a Component.