void Debug() { PrintFormat( "Array count: %1", Count()); for ( int i = 0; i < Count(); i++ ) { T item = Get(i); if ( item ) { PrintFormat("[%1] => %2", i, string.ToString(item)); } } }
Function above is taken from core/scripts/Core/proto/Types.c, the issue here is if ( item ) part, if we use a non reference type as T, this check becomes incorrect, for example:
array<int> arrayOfInts = { 0, 0, 1 }; arrayOfInts.Debug();
Output of the above code is:
SCRIPT : Array count: 3 SCRIPT : [2] => 1
Only the third value is printed, because it's non zero, the first two values are zeros, and because of that, if ( item ) evaluates false. Why is this check even needed in the first place? string.ToString can take a nullref no problem.