Bug 816 – .dup for associative arrays

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2007-01-07T19:08:00Z
Last change time
2014-02-15T13:21:50Z
Assigned to
nobody
Creator
dlang-bugzilla

Comments

Comment #0 by dlang-bugzilla — 2007-01-07T19:08:39Z
Since associative arrays are reference types, the language currently doesn't provide a straight-forward way to duplicate an associative array. As a small enhancement towards general language consistency, I would like to suggest a .dup property, like for dynamic arrays, which returns a copy of the associative array.
Comment #1 by wbaxter — 2007-04-25T20:26:28Z
I second that. I was surprised to find out just now when the compiler told me it didn't exist for AAs. (Is there a workaround? Does assigning to another AA make a copy?)
Comment #2 by dlang-bugzilla — 2007-04-25T20:28:01Z
The "workaround" is: foreach(key,value;aa1)aa2[key]=value; This can easily be made into a template function.
Comment #3 by y0uf00bar — 2010-04-17T04:33:49Z
See enhancement 4098
Comment #4 by y0uf00bar — 2010-04-17T04:50:51Z
I added a .dup to enhancement 4098
Comment #5 by andrei — 2011-01-08T12:01:18Z
druntime revision 488.