associative arrays

Kapps Kapps at NotValidEmail.com
Sat Jan 7 23:39:24 PST 2012


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.

On 07/01/2012 4:11 PM, RenatoL wrote:
> Very quick question
>
> import std.stdio;
> void main()
> {
> 	auto arr1 = ["uno":1, "due":2, "tre":3];
> 	arr1.remove("xxx");
> }
>
> also in this case the compiler does not say anything and the
> program goes out silently ... why? Would not it be better if an
> exception was raised? After all if i write:
>
> writeln(arr1["xxx"]);
>
> runtime expresses its disappointment...



More information about the Digitalmars-d-learn mailing list