diff options
author | Gautam Kotian <gautam.kotian@gmail.com> | 2015-10-15 07:32:48 +0200 |
---|---|---|
committer | Gautam Kotian <gautam.kotian@gmail.com> | 2015-10-15 16:55:10 +0200 |
commit | a77d0264c9df6ac2ac4c1e2202e352704580c579 (patch) | |
tree | d7c61461e8b4b9e31cf0313da86a3918c750ee98 /d.html.markdown | |
parent | d136abe95434a94bd70a981b1ea2bf0ee1dbf636 (diff) |
Make the code compilable
and add some additional comments to explain what's happening.
Diffstat (limited to 'd.html.markdown')
-rw-r--r-- | d.html.markdown | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/d.html.markdown b/d.html.markdown index ea1c1700..80c1dc65 100644 --- a/d.html.markdown +++ b/d.html.markdown @@ -176,13 +176,21 @@ class MyClass(T, U) { // And we use them in this manner: void main() { - auto mc = MyClass!(int, string); + auto mc = new MyClass!(int, string)(7, "seven"); - mc.data = 7; - mc.other = "seven"; + // Import the 'stdio' module from the standard library for writing to + // console (imports can be local to a scope). + import std.stdio; - writeln(mc.data); - writeln(mc.other); + // Call the getters to fetch the values. + writefln("Earlier: data = %d, str = %s", mc.data, mc.other); + + // Call the setters to assign new values. + mc.data = 8; + mc.other = "eight"; + + // Call the getters again to fetch the new values. + writefln("Later: data = %d, str = %s", mc.data, mc.other); } ``` |