[Gambas-user] About array Initialization
Fabien Bodard
gambas.fr at ...626...
Fri Nov 19 08:48:45 CET 2010
2010/11/19 Demosthenes Koptsis <demosthenesk at ...626...>:
> ok,
> another question...
>
> the only way to init a static array aNumbers[10] is
>
> aNumbers[0]=1
> aNumbers[1]=2
> aNumbers[2]=12
> aNumbers[3]=13
> ....
yes a static array is not an object ... that's why it's a little bit
deprecated :)
anther way :
dim htmpArray as integer[]= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
dim i as integer
For i = 0 to hTmparray.max
aNumbers.add( htmpArray[i])
next
Stupid ... isn't it ?
the power of modern langage is to simplify the synthax with objects...
>
>
> On Fri, 2010-11-19 at 01:36 +0100, Benoît Minisini wrote:
>> > 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,
>>
>
>
>
> ------------------------------------------------------------------------------
> Beautiful is writing same markup. Internet Explorer 9 supports
> standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
> Spend less time writing and rewriting code and more time creating great
> experiences on the web. Be a part of the beta today
> http://p.sf.net/sfu/msIE9-sfdev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
--
Fabien Bodard
More information about the User
mailing list