Generic array

2011-11-15 Thread RenatoL
##[3] arr = [0, "aa", 2.4]; What can i put instead of ##? In C#, just for example, i can write: object[] ar1 = new object[3]; ar1[0] = 1; ar1[1] = "hello"; ar1[2] = 'a'; and it works. But in D Object[3] arr0 = [0, "aa", 2.4]; and compiler complains

Re: Generic array

2011-11-15 Thread bioinfornatics
Le mardi 15 novembre 2011 à 23:15 +, RenatoL a écrit : > ##[3] arr = [0, "aa", 2.4]; > > What can i put instead of ##? > > In C#, just for example, i can write: > > object[] ar1 = new object[3]; > ar1[0] = 1; > ar1[1] = "hello"; > ar1[2] = 'a'; > > and it works. But in D > > Object[3] arr0

Re: Generic array

2011-11-15 Thread Jesse Phillips
On Wed, 16 Nov 2011 00:30:44 +0100, bioinfornatics wrote: > this works: -- > import std.string; > import std.variant; > import std.stdio; > > void main( string[] args ){ > Variant[] array = [ cast(Variant)1u , cast(Variant)"hi", > cast(Variant)-

Re: Generic array

2011-11-16 Thread Dejan Lekic
RenatoL wrote: > ##[3] arr = [0, "aa", 2.4]; > > What can i put instead of ##? > > In C#, just for example, i can write: > > object[] ar1 = new object[3]; > ar1[0] = 1; > ar1[1] = "hello"; > ar1[2] = 'a'; > > and it works. But in D > > Object[3] arr0 = [0, "aa", 2.4]; > > and compiler compl

Re: Generic array

2011-11-16 Thread Jonathan M Davis
On Wednesday, November 16, 2011 08:33:04 Dejan Lekic wrote: > RenatoL wrote: > > ##[3] arr = [0, "aa", 2.4]; > > > > What can i put instead of ##? > > > > In C#, just for example, i can write: > > > > object[] ar1 = new object[3]; > > ar1[0] = 1; > > ar1[1] = "hello"; > > ar1[2] = 'a'; > > > >

Re: Generic array

2011-11-17 Thread RenatoL
Ok, tk u all. I guess this is a very poor approach if we are looking for performance

Re: Generic array

2011-11-17 Thread Jonathan M Davis
On Thursday, November 17, 2011 14:41 RenatoL wrote: > Ok, tk u all. > I guess this is a very poor approach if we are looking for > performance Mixing types like that in an array is not a normal thing to do. However, if you're looking to hold a specific number of items of diverse types (particula