Finding out about D - 102

Ary Borenszweig ary at esperanto.org.ar
Mon May 11 11:00:00 PDT 2009


Steve Teale wrote:
> OK, so structs are a different beast in D than they are in C++. This results in one of my most common pitfalls. I'll find myself writing:
> 
> struct A
> {
>    int a;
>    int b;
> }
> 
> A[] nameTooLong = ...;
> 
> foreach (whatever; thingie)
> {
>    nameTooLong[whatever.whatever].a = whatever.x*3;
>    nameTooLong[whatever.whatever].b = whatever.y/3;

with(nameTooLong[whatever.whatever]) {
   a = whatever.x*3;
   b = whatever.y/3;
}


More information about the Digitalmars-d-learn mailing list