array idioms

Jonathan M Davis jmdavisProg at gmx.com
Fri Feb 25 12:40:43 PST 2011


On Friday 25 February 2011 12:30:00 Andrej Mitrovic wrote:
> On 2/25/11, Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> >> * insert an element in a dyn array
> > 
> > Same as remove. There's no function for doing it at the moment.
> 
> std.array.insert:
> 
> int[] a = [ 1, 2, 3, 4 ];
> a.insert(2, [ 1, 2 ]);
> assert(a == [ 1, 2, 1, 2, 3, 4 ]);
> 
> afaik insert was missing from the documentation in the last release
> (I've reported it), but now it's back in. So maybe that's why nobody
> knew about it.

Ah. Good to know. Its not the sort of thing that I'm generally looking to do, 
however, so I don't tend to think about it. I don't believe that I've ever seen 
the function in the docs before, so that would explain why didn't know about it.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list