mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-26 09:21:00 +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:
|
||||
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);
|
||||
}
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user