Skip to content

Commit 259ebc7

Browse files
committed
Add links for casting array (literals)
Also make examples runnable.
1 parent 19c29c7 commit 259ebc7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

spec/expression.dd

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ $(H3 $(LNAME2 cast_array, Arrays))
10741074
as a type paint, with the array length adjusted to match any change in
10751075
element size. If there's not a match, a runtime error is generated.)
10761076

1077+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
10771078
---
10781079
import std.stdio;
10791080

@@ -1090,7 +1091,9 @@ $(H3 $(LNAME2 cast_array, Arrays))
10901091
return 0;
10911092
}
10921093
---
1094+
)
10931095

1096+
$(DDOC_SEE_ALSO $(RELATIVE_LINK2 cast_array_literal, Casting array literals).)
10941097

10951098
$(H3 $(LNAME2 cast_static_array, Static Arrays))
10961099

@@ -1618,11 +1621,14 @@ $(GNAME ArrayLiteral):
16181621
}
16191622
---
16201623

1624+
$(H3 $(LNAME2 cast_array_literal, Casting))
1625+
16211626
$(P When array literals are cast to another array type, each
16221627
element of the array is cast to the new element type.
1623-
When arrays that are not literals are cast, the array is
1628+
When arrays that are not literals $(RELATIVE_LINK2 cast_array, are cast), the array is
16241629
reinterpreted as the new type, and the length is recomputed:)
16251630

1631+
$(SPEC_RUNNABLE_EXAMPLE_RUN
16261632
---
16271633
import std.stdio;
16281634

@@ -1641,6 +1647,7 @@ $(GNAME ArrayLiteral):
16411647
writeln(rt); // writes [257]
16421648
}
16431649
---
1650+
)
16441651

16451652
In other words, casting literal expression will change the literal type.
16461653

0 commit comments

Comments
 (0)