Skip to content

Commit 4398cc0

Browse files
ntreldlang-bot
authored andcommitted
[spec/hash-map] Document new AA
1 parent 4b82606 commit 4398cc0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

spec/hash-map.dd

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ $(SPEC_RUNNABLE_EXAMPLE_RUN
406406
int[int] aa; // defaults to null
407407
int[int] aa2 = aa; // copies the null reference
408408

409+
assert(aa is null);
409410
aa[1] = 1;
410411
assert(aa2.length == 0); // aa2 still is null
411412
aa2 = aa;
@@ -414,6 +415,20 @@ $(SPEC_RUNNABLE_EXAMPLE_RUN
414415
------
415416
)
416417

418+
$(P A $(GLINK2 expression, NewExpression) allows constructing an associative array instance
419+
immediately, rather than when $(DDSUBLINK spec/hash-map, construction_assignment_entries, inserting a key).)
420+
421+
$(SPEC_RUNNABLE_EXAMPLE_RUN
422+
---
423+
int[string] a = new int[string];
424+
auto b = a; // a and b point to the same AA instance
425+
426+
assert(b !is null);
427+
a["1"] = 1;
428+
assert(b["1"] == 1);
429+
---
430+
)
431+
417432
$(H2 $(LNAME2 properties, Properties))
418433

419434
$(P Properties for associative arrays are:)

0 commit comments

Comments
 (0)