bearophile wrote:
simendsjo:
I haven't worked much with AA's, but I find the key in aa returns a
reference to the value to be handy. I think it's better than the following:
int value;
if( 1 in a )
value = a[1];
or a[1] in a try/catch or other implementations.
Your examples have shown
unittest
{
auto a = [1:2];
auto p = 1 in a;
// can p be invalidated by rehashing?
// That is pointing to a different item or a memory location used for
other things?
auto b = a.rehash;
// The spec also says it orders in place, but returns the
simendsjo:
auto a = [1:2];
auto p = 1 in a;
// can p be invalidated by rehashing?
Yes, I presume it can. p is meant for immediate consumption only.
// The spec also says it orders in place, but returns the reorganized
array...
// Is the spec right? That it
On 08.08.2010 17:51, bearophile wrote:
simendsjo:
auto a = [1:2];
auto p = 1 in a;
// can p be invalidated by rehashing?
Yes, I presume it can. p is meant for immediate consumption only.
// The spec also says it orders in place, but returns the reorganized
simendsjo:
I haven't worked much with AA's, but I find the key in aa returns a
reference to the value to be handy. I think it's better than the following:
int value;
if( 1 in a )
value = a[1];
or a[1] in a try/catch or other implementations.
Your examples have shown me that