I have a genericArray of int
[indent=4]
init
var a = new GenericArray of int
for var i = 1 to 3 do a.add (i)
say: Func of int = def (v)
stdout.printf ("%d ", v)
var end = a.length - 1
these all output 1 2 3
for var i = 0 to end do stdout.printf ("%d ", a[i])
for var i = 0 to end do stdout.printf ("%d ", a.data[i])
a.foreach (say)
but this output is 1 0 2 ?
Why the out put is not 1 2 3
for val in a.data do stdout.printf ("%d ", val)
If I set the data field:
var a = new GenericArray of int
a.data = {1, 2, 3}
below: It will output 1 2 3
for val in a.data do stdout.printf ("%d ", val)
everything is fine?
But these all output 1 3 0
for var i = 0 to end do stdout.printf ("%d ", a[i])
for var i = 0 to end do stdout.printf ("%d ", a.data[i])
a.foreach (say)
Why it behave so oddly?