Question by
Harryliu · May 19, 2016 at 04:19 PM ·
listclasssyntax-error
This returns a syntax error?
This:
#pragma strict
import System.Collections.Generic;
public var ingName : String;
public var ingTime : int;
public class AddIngredient extends Monobehaviour {
var ingredients = new List.<Ingredient>();
function OnTriggerEnter (Col : Collider) {
if(Col.Tag("Ingredients")) {
ingName = Col.gameObject.GetComponent(Ingredient).itemName;
ingTime = Col.gameObject.GetComponent(Ingredient).cookTime;
ingredients.Add(new Ingredient(ingName, ingTime);
ingredients.Sort();
}
}
}
Returns this error:
Assets/AddIngredient.js(20,73): BCE0044: expecting ), found ';'. Assets/AddIngredient.js(20,74): UCE0001: ';' expected. Insert a semicolon at the end.
I can't seem to find the error?
Comment
Best Answer
Answer by Zoogyburger · May 19, 2016 at 05:35 PM
In the line
ingredients.Add(new Ingredient(ingName, ingTime);
You forgot to put a closing parenthesis. So try this instead:
ingredients.Add(new Ingredient(ingName, ingTime));