(1.0) Clearing out an Associative Array

Steven Schveighoffer schveiguy at yahoo.com
Thu Jan 31 19:22:23 PST 2008


"Bill Baxter" wrote
> jicman wrote:
>> Steven Schveighoffer Wrote:
>>
>>> "jicman" wrote
>>>> Greetings.
>>>>
>>>> Long time no write. :-)
>>>>
>>>> I know that I can get the keys of an Associative array and do a foreach 
>>>> loop and remove the keys of the array, but is there an easier and 
>>>> quicker way?  I know that I can set any non-Associative array to [], 
>>>> ie,
>>>>
>>>> myArr = [];
>>>>
>>>> and that is sufficient or set the length to 0; but how about the 
>>>> Associative arrays?  Is there a quick way of doing this?
>>>>
>>>> thanks,
>>>>
>>>> josé
>>> How about
>>>
>>> myArr = myArr.init;
>>>
>>> Works for both associative and standard arrays
>>>
>>
>> Thanks Steve.  This one worked.
>
> Are you implying that
>    myArr=null;
> did not work?  because it should.  And it's less typing.  And avoids you 
> having to repeat yourself.  :-)

Ha ha! jicman liked my idea better.  Jealous much?

j/k, I like your solution better :)

-Steve 




More information about the Digitalmars-d-learn mailing list