Object to int

I use an Array to load int values and shuffle. But when I put “#pragma strict” and get a value of the array I get the error: BCE0022: Cannot convert ‘Object’ to ‘int’.

#pragma strict

var numbers : Array;
numbers = new Array(6);
var x : int = Random.Range(1,10);
numbers[0] = x;
...
var n : int;
n = numbers[0];

Maybe I could use an int vector “int”. But I have made the entire game without “#pragma strict” and also I use the method Array.splice.

Don’t use Array, which slow and not type-safe. Use List instead, then you don’t have to worry about casting.

#pragma strict
import System.Collections.Generic;

var numbers = new List.<int>();
for (var i = 0; i < 6; i++) {
	numbers.Add(Random.Range(1, 10));
}
...
var n = numbers[0];