Associative array for array of classes
Sean Kelly
sean at f4.ca
Thu Apr 27 20:12:10 PDT 2006
The correct use of AAs is so intuitive I'm amazed anyone ever gets it
wrong. It's times like this when I wish I'd been more vocal about
actually liking the old syntax :-p
Alberto Simon wrote:
> You should use '(("3" in assoc) == null)' instead of '(assoc["3"] is null)'
>
> Regards,
> Alberto Simon
> "Stewart Gordon" <smjg_1998 at yahoo.com> escribió en el mensaje
> news:e2qh6d$1lfk$2 at digitaldaemon.com...
>> clayasaurus wrote:
>> <snip>
>>> Class[char[]] assoc;
>>> assoc["3"] = new Class;
>>>
>>> Now, lets say I want to test if assoc["3"] has already been initialized
>>> before I allocate it, but testing it with
>>>
>>> if (assoc["3"] is null)
>>> assoc["3"] = new Class;
>>>
>>> I get a seg fault.
>> <snip>
>>
>> That's strange. It should be an ArrayBoundsError.
>>
>> Stewart.
>
>
More information about the Digitalmars-d-learn
mailing list