- Home /
IntArray vs BoolArray JS via C# - MultiDim.cs
For a JS multidimensional array of boolean's, would creating a new boolean function (for MultiDim.cs in Standard Assets/Scripts) be better than using the IntArray
for http://www.unifycommunity.com/wiki/index.php?title=JavascriptMultiDimArrays
public static int[,] BoolArray (int a, int b) { return new bool[a,b]; }
Answer by Mike 3 · Dec 23, 2010 at 03:23 AM
I would make the separate function yes, though it needs to be bool[,] not int[,] as your paste shows.
Or, possibly better:
public static T[,] TArray<T> (int width, int height)
{
return new T[width, height];
}
which you would use like this:
var multi = TArray.<boolean>(width, height);
I get this error: "A namespace can only contain types and namespace declarations"
oops - works when i put a class around it.. why is TArray a bad name, and also if I only anticipate using a multidimensional array of booleans, would it be any performance loss to use this abstract array?
Not a bad name per se, just a bit meh. Either way, no performance loss, it's still a bool[,] behind the scenes when you create it