Skip to content

Commit 51a7b93

Browse files
committed
Make static array example runnable
1 parent e1bf977 commit 51a7b93

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

spec/expression.dd

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,23 +1103,22 @@ $(H3 $(LNAME2 cast_static_array, Static Arrays))
11031103
The cast is done as a type paint (aka a reinterpret cast).
11041104
The contents of the array are not changed.)
11051105

1106-
---
1107-
import core.stdc.stdio;
1108-
1109-
void main()
1110-
{
1111-
byte[16] b = 3;
1106+
$(SPEC_RUNNABLE_EXAMPLE_RUN
1107+
---
1108+
byte[16] b = 3; // set each element to 3
1109+
assert(b[0] == 0x03);
11121110
int[4] ia = cast(int[4]) b;
1111+
// print elements as hex
11131112
foreach (i; ia)
1114-
printf("%x\n", i);
1113+
writefln("%x", i);
11151114
/* prints:
11161115
3030303
11171116
3030303
11181117
3030303
11191118
3030303
11201119
*/
1121-
}
1122-
---
1120+
---
1121+
)
11231122

11241123
$(H3 $(LNAME2 cast_floating, Floating Point))
11251124

0 commit comments

Comments
 (0)