Skip to content

Commit 6afb0dd

Browse files
authored
Make the runnable example actually work (#4202)
The runnable example added yesterday unfortunately did not work. Changed the code so that it actually works. Added also another features of an interpolated string. I noticed during Tsoding's stream and also from personal experience, that discovering features often happen by looking for something else.
1 parent 1ef78cb commit 6afb0dd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

articles/ctod.dd

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,13 @@ ulong[string] map = ["hello" : 1616515,
646646
"goodbye" : 42,
647647
"maybe" : ulong.max
648648
];
649-
string s = "goodbye";
650-
651-
writeln("number is ", map[s]);
649+
unittest
650+
{
651+
import std.stdio;
652+
writeln("number is ", map["goodbye"]);
653+
writeln(i"map contains $(str.length) elements");
654+
writeln("map is ", map);
655+
}
652656
----------------------------
653657
)
654658

0 commit comments

Comments
 (0)