[Gambas-user] About array Initialization
Benoît Minisini
gambas at ...1...
Fri Nov 19 01:36:11 CET 2010
> Good morning to all!
>
> we can do an array initialization such as
>
> DIM aNumbers AS Integer[] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>
> but not
> DIM aNumbers AS Integer[10] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>
>
> why is that?
No real reason, except that the second syntax is useless: you are creating a
array of ten integers that you are replacing with another array of ten
integers. The first array is freed.
Dim xxx As yyy[] = [ ... ] is not just an array initialization like in C. It
actually runs the [ ... ] operator to create an array at runtime.
Regards,
--
Benoît Minisini
More information about the User
mailing list