digitalmars.D - AA getLValue
- Martin Nowak (10/10) Mar 27 2012 Does anybody know an efficient way to get/create-if-missing an lvalue AA...
- simendsjo (4/14) Mar 27 2012 Depends on your needs, but I find aa.get(key, defaultValue) nice. It
Does anybody know an efficient way to get/create-if-missing an lvalue AA
entry.
I commonly resort to this, but it uses three lookups.
auto p = key in aa;
if (p is null)
{
aa[key] = inital;
p = key in aa;
}
//...
Mar 27 2012
On Tue, 27 Mar 2012 11:35:51 +0200, Martin Nowak <dawg dawgfoto.de> wrote:
Does anybody know an efficient way to get/create-if-missing an lvalue AA
entry.
I commonly resort to this, but it uses three lookups.
auto p = key in aa;
if (p is null)
{
aa[key] = inital;
p = key in aa;
}
//...
Depends on your needs, but I find aa.get(key, defaultValue) nice. It
doesn't set the value though:
auto p = aa.get(key, initial);
Mar 27 2012








simendsjo <simendsjo gmail.com>