mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-22 21:52:31 +03:00
Make the code compilable
and add some additional comments to explain what's happening.
This commit is contained in:
parent
d136abe954
commit
a77d0264c9
@ -176,13 +176,21 @@ class MyClass(T, U) {
|
|||||||
|
|
||||||
// And we use them in this manner:
|
// And we use them in this manner:
|
||||||
void main() {
|
void main() {
|
||||||
auto mc = MyClass!(int, string);
|
auto mc = new MyClass!(int, string)(7, "seven");
|
||||||
|
|
||||||
mc.data = 7;
|
// Import the 'stdio' module from the standard library for writing to
|
||||||
mc.other = "seven";
|
// console (imports can be local to a scope).
|
||||||
|
import std.stdio;
|
||||||
|
|
||||||
writeln(mc.data);
|
// Call the getters to fetch the values.
|
||||||
writeln(mc.other);
|
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);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user