Help - Basic function error

Hi all, i’m just trying my unity training from walker studio, but i have some error here and i don’t understand it, because in the video i watch the source can work properly.

this is my error :
Assets/BasicScripting.js(275,19): BCE0051: Operator ‘+’ cannot be used with a left hand side of type ‘Object’ and a right hand side of type ‘Object’.

Assets/BasicScripting.js(276,23): BCE0051: Operator ‘<’ cannot be used with a left hand side of type ‘int’ and a right hand side of type ‘Object’.

my error at function Addition and function Counter.

this is my source :

function update(){
PrintToScreen(21);
Addition(2,4);
Counter(20);
}

function PrintToScreen (text) {
	print(text);
}

function Addition (a,b) {
	var c = a + b;
	print(c);
}

function Counter (num) {
	var x : int;
	for(x = 0 ; x < num ; x++){
		print(x);
	}
}

Anyone can explain it to me please? :smile:

Thanks :smile:

function Addition (a:int,b:int) {
    var c = a + b;
    print(c);
}

function Counter (num:int) {
    var x : int;
    for(x = 0 ; x < num ; x++){
        print(x);
    }

It’s being sent as an object, type inference not workie i guess, do the same for the Counter function.

You need to declare the types, otherwise it doesn’t know what it’s working with.

Assuming Addition is using integers…

function Addition (a : int, b : int) {

function Counter (num : int) {

wow, it’s work, haha…

but i wonder, why source from the video can work properly, it’s make me confused -_-

but anyway thanks :smile: