May 09, 2006
antonio schrieb am 2006-05-07:

<snip>

> ¿Standard D offers some way to build a dynamic array on the fly? (like c#, java)
>
>     Person someone = new Person();
>     Person anotherone = new Person();
>
>     int count = new Person[]{ someone, anotherone };  // Hoy do you do
>     this on D?

shouldn't this be:
# Person[] count = new Person[]{ someone, anotherone };


D kludge:
#
# template makeDynArray(T){
#     T[] makeDynArray(T[] raw ...){
#         return raw.dup;
#     }
# }
#

#
# Person[] count = makeDynArray!(Person)(someone, anotherone);
#

Thomas


May 09, 2006
Thanks a lot.

Really nice... I think, I have to participate more actively in the d.D.learn forum :-p.


Thomas Kuehne escribió:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> antonio schrieb am 2006-05-07:
> 
> <snip>
> 
>> �Standard D offers some way to build a dynamic array on the fly? (like c#, java)
>>
>>     Person someone = new Person();
>>     Person anotherone = new Person();
>>
>>     int count = new Person[]{ someone, anotherone };  // Hoy do you do
>>     this on D?
> 
> shouldn't this be:
> # Person[] count = new Person[]{ someone, anotherone };
> 
> 
> D kludge:
> #
> # template makeDynArray(T){
> #     T[] makeDynArray(T[] raw ...){
> #         return raw.dup;
> #     }
> # }
> #
> 
> #
> # Person[] count = makeDynArray!(Person)(someone, anotherone);
> #
> 
> Thomas
> 
> 
> -----BEGIN PGP SIGNATURE-----
> 
> iD0DBQFEX0KM3w+/yD4P9tIRAmpKAJiMFtf5O+Rwk40lwN1BRZtK6mo9AJYwC5e9
> vvb3XmuoYeQbRXm2340Y
> =Knpn
> -----END PGP SIGNATURE-----
May 09, 2006
Thomas Kuehne escribió:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> antonio schrieb am 2006-05-07:
> 
> <snip>
> 
>> �Standard D offers some way to build a dynamic array on the fly? (like c#, java)
>>
>>     Person someone = new Person();
>>     Person anotherone = new Person();
>>
>>     int count = new Person[]{ someone, anotherone };  // Hoy do you do
>>     this on D?
> 
> shouldn't this be:
> # Person[] count = new Person[]{ someone, anotherone };
int count = new Person[]{ someone, anotherone }.length
> 
> 
> D kludge:
> #
> # template makeDynArray(T){
> #     T[] makeDynArray(T[] raw ...){
> #         return raw.dup;
> #     }
> # }
> #
> 
> #
> # Person[] count = makeDynArray!(Person)(someone, anotherone);
> #
> 
> Thomas
> 
> 
> -----BEGIN PGP SIGNATURE-----
> 
> iD0DBQFEX0KM3w+/yD4P9tIRAmpKAJiMFtf5O+Rwk40lwN1BRZtK6mo9AJYwC5e9
> vvb3XmuoYeQbRXm2340Y
> =Knpn
> -----END PGP SIGNATURE-----
1 2
Next ›   Last »