Finding out about D - 102
Steve Teale
steve.teale at britseyeview.com
Mon May 11 22:59:31 PDT 2009
Ary Borenszweig Wrote:
> 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;
> }
Ary,
Yes I use with quite often, it's when I have two of the beasts where I want to use with at the same time that I have fallen into this.
Now that I've rubbed my nose in it I'm sure I won't do it again.
More information about the Digitalmars-d-learn
mailing list