Re: Clearing associative array.

2016-03-15 Thread Steven Schveighoffer via Digitalmars-d-learn

On 3/12/16 8:09 AM, Adam D. Ruppe wrote:

On Saturday, 12 March 2016 at 12:59:02 UTC, ciechowoj wrote:

Nice article :), thanks. But still, what about clear()? In the
documentation https://dlang.org/spec/hash-map.html#properties there is
written that associative arrays have clear property.


I don't think that actually works... might be out of date documentation,
I'm not sure.


Opposite. The next version of dmd will have a clear property.

Apparently, we don't have a good system to merge doc changes in concert 
with future master releases. Whatever gets pulled apparently gets built 
as the current docs.


See PR: https://github.com/D-Programming-Language/dlang.org/pull/1217

-Steve


Re: Clearing associative array.

2016-03-13 Thread ciechowoj via Digitalmars-d-learn

On Sunday, 13 March 2016 at 13:42:02 UTC, cym13 wrote:
The problem was brought up a few days ago (can't remember 
where) and it happens to be a documentation mistake: there is a 
clear() method planned but for a future release (the next one?).


That would be great : )


Re: Clearing associative array.

2016-03-13 Thread cym13 via Digitalmars-d-learn

On Saturday, 12 March 2016 at 12:59:02 UTC, ciechowoj wrote:

On Saturday, 12 March 2016 at 12:42:04 UTC, Adam D. Ruppe wrote:

On Saturday, 12 March 2016 at 12:34:16 UTC, ciechowoj wrote:
If above doesn't work how am I supposed to clear the array? 
`x = string[string].init;` is somewhat ugly.


Read the Tip of the Week section here:

http://arsdnet.net/this-week-in-d/dec-13.html

Short answer: use `= null` to clear the AA. [] doesn't work 
just because the compiler is a bit stupid about the type you 
intend it to be, but null works fine.


BTW you might want to glance through more of the issues for 
the tip section too and see if there's more that interest you.


Nice article :), thanks. But still, what about clear()? In the 
documentation https://dlang.org/spec/hash-map.html#properties 
there is written that associative arrays have clear property.


The problem was brought up a few days ago (can't remember where) 
and it happens to be a documentation mistake: there is a clear() 
method planned but for a future release (the next one?).


Re: Clearing associative array.

2016-03-12 Thread Adam D. Ruppe via Digitalmars-d-learn

On Saturday, 12 March 2016 at 12:59:02 UTC, ciechowoj wrote:
Nice article :), thanks. But still, what about clear()? In the 
documentation https://dlang.org/spec/hash-map.html#properties 
there is written that associative arrays have clear property.


I don't think that actually works... might be out of date 
documentation, I'm not sure.


Re: Clearing associative array.

2016-03-12 Thread ciechowoj via Digitalmars-d-learn

On Saturday, 12 March 2016 at 12:42:04 UTC, Adam D. Ruppe wrote:

On Saturday, 12 March 2016 at 12:34:16 UTC, ciechowoj wrote:
If above doesn't work how am I supposed to clear the array? `x 
= string[string].init;` is somewhat ugly.


Read the Tip of the Week section here:

http://arsdnet.net/this-week-in-d/dec-13.html

Short answer: use `= null` to clear the AA. [] doesn't work 
just because the compiler is a bit stupid about the type you 
intend it to be, but null works fine.


BTW you might want to glance through more of the issues for the 
tip section too and see if there's more that interest you.


Nice article :), thanks. But still, what about clear()? In the 
documentation https://dlang.org/spec/hash-map.html#properties 
there is written that associative arrays have clear property.


Re: Clearing associative array.

2016-03-12 Thread Adam D. Ruppe via Digitalmars-d-learn

On Saturday, 12 March 2016 at 12:34:16 UTC, ciechowoj wrote:
If above doesn't work how am I supposed to clear the array? `x 
= string[string].init;` is somewhat ugly.


Read the Tip of the Week section here:

http://arsdnet.net/this-week-in-d/dec-13.html

Short answer: use `= null` to clear the AA. [] doesn't work just 
because the compiler is a bit stupid about the type you intend it 
to be, but null works fine.


BTW you might want to glance through more of the issues for the 
tip section too and see if there's more that interest you.