@@ -2517,13 +2517,13 @@ $(GNAME ArgumentList):
2517
2517
collected) heap.
2518
2518
)
2519
2519
2520
- $(P The *Type* form constructs an instance of a type and default-initializes it.)
2520
+ $(P The `new` *Type* form constructs an instance of a type and default-initializes it.)
2521
2521
$(P The *Type(ArgumentList)* form allows passing either a single initializer
2522
2522
of the same type, or multiple arguments for more complex types.
2523
2523
For class types, *ArgumentList* is passed to the class constructor.
2524
2524
For a dynamic array, the argument sets the initial array length.
2525
2525
For multidimensional dynamic arrays, each argument corresponds to
2526
- an initial length.)
2526
+ an initial length (see $(RELATIVE_LINK2 new_multidimensional, below)) .)
2527
2527
2528
2528
$(SPEC_RUNNABLE_EXAMPLE_RUN
2529
2529
---
@@ -2537,10 +2537,6 @@ $(GNAME ArgumentList):
2537
2537
2538
2538
auto a = new int[](2);
2539
2539
assert(a.length == 2);
2540
-
2541
- int[][] m = new int[][](10, 5);
2542
- assert(m.length == 10);
2543
- assert(m[0].length == 5);
2544
2540
---
2545
2541
)
2546
2542
@@ -2552,6 +2548,15 @@ $(GNAME ArgumentList):
2552
2548
$(NOTE It is not possible to allocate a static array directly with
2553
2549
`new` (only by using a type alias).)
2554
2550
2551
+ $(P The result is a $(DDSUBLINK const3, unique-expressions, unique expression)
2552
+ which can implicitly convert to other qualifiers:)
2553
+
2554
+ ---
2555
+ immutable o = new Object;
2556
+ ---
2557
+
2558
+ $(H4 $(LNAME2 new_class, Class Instantiation))
2559
+
2555
2560
$(P If a $(I NewExpression) is used with a class type as an initializer for
2556
2561
a function local variable with $(DDSUBLINK spec/attribute, scope, `scope`) storage class,
2557
2562
then the instance is $(DDSUBLINK spec/attribute, scope-class-var, allocated on the stack).
@@ -2579,13 +2584,18 @@ $(H4 $(LNAME2 new_multidimensional, Multidimensional Arrays))
2579
2584
2580
2585
$(P To allocate the nested arrays, multiple arguments can be used:)
2581
2586
2587
+ $(SPEC_RUNNABLE_EXAMPLE_RUN
2582
2588
---------------
2583
2589
int[][][] bar;
2584
- ...
2585
2590
bar = new int[][][](5, 20, 30);
2591
+
2592
+ assert(bar.length == 5);
2593
+ assert(bar[0].length == 20);
2594
+ assert(bar[0][0].length == 30);
2586
2595
---------------
2596
+ )
2587
2597
2588
- The code above is equivalent to:
2598
+ The assignment above is equivalent to:
2589
2599
2590
2600
----------
2591
2601
bar = new int[][][5];
0 commit comments