associative arrays

Jonathan M Davis jmdavisProg at
Sun Jan 8 00:09:14 PST 2012

On Sunday, January 08, 2012 01:39:24 Kapps wrote:
> For most languages (such as C# and maybe Java), the Remove method on
> collections returns a boolean indicating whether it was removed. So you
> could write:
> enforce(MyAA.remove("lenght"))
> or
> bool Result = MyAA.remove("lenght");
> assert(Result);
> I'm not sure why it doesn't in D, but I thought I remembered seeing a
> pull request or change that added it. Maybe I'm imagining things since I
> can't find it now.

There _is_ extra cost in returning bool rather than void, but I'm not at all 
sure that it's unreasonable to incur that cost. std.container.RedBlackTree's 
remove function returns how many elements were removed. Other functions in 
Phobos do similar in similar situations.

It probably merits an enhancement request.

- Jonathan M Davis

More information about the Digitalmars-d-learn mailing list