module main; // Computes average line length for standard input. import std.stdio; struct Mystruct { int eight = 8; int get() { return 9; } } class Myclass { static this() { writeln("Myclass object constructed."); } // a static constructor static ~this() { writeln("Myclass object destroyed."); } // a static destructor Mystruct astruct; alias astruct this; } int sctest() { auto aclass = new Myclass; int i = aclass.eight; // i == 8 i = aclass.get(); // i == 9 delete aclass; return i; } void main() { ulong all_lines = 0; double movingAverage = 0; sctest(); // some OOP writeln("Enter records and see the moving average of record lengths after each go exits"); foreach (line; stdin.byLine()) { ++all_lines; movingAverage = ((movingAverage * (all_lines - 1)) + line.length) / all_lines; writeln("Average record length: ", movingAverage); } }