C# code sample

Jesse Phillips jessekphillips+D at gmail.com
Mon Jan 24 12:04:01 PST 2011


Simen kjaeraas Wrote:

> pragma <the_ignorator at hotmail.com> wrote:
> 
> > Hi i come from a c# background
> >
> > I would like to write the following code in the according D style but  
> > i'm not
> > sure howto do it
> >
> > c# code:
> > void foo(IEnumerable<double[]> data)
> > {
> >   foreach (var d in data)
> >   {
> >     do_some_stuff(d);
> >   }
> > }
> >
> > i guess the D equivalent to IEnumerable is Range? how would it look like  
> > in D?
> 
> void foo( R )( R data )
>      if ( isInputRange!R && is( ElementType!R == double ) )
> {
>      foreach ( d; data ) {
>          do_some_stuff( d );
>      }
> }
> 
> -- 
> Simen

I thank it should be:  is( ElementType!R == double[] ) )



More information about the Digitalmars-d-learn mailing list