auto: useful, annoying or bad practice?

KingJoffrey KingJoffrey at KingJoffrey.com
Wed May 16 10:52:42 UTC 2018


On Monday, 30 April 2018 at 21:11:07 UTC, Gerald wrote:
> So I'm curious, what's the consensus on auto?

In the example below, what would I use, besides auto?

------------------------
module test;

void main ()
{
     import std.stdio : writeln;
     auto result = newKing("King Joffrey");
     writeln(result.getName);
}

auto newKing(string name)
{
     class King
     {
         private string _name;
         public string getName() { return this._name ~ " : the one 
true king!"; }
         this() { this._name = name; }
     }

     return new King;
}

------------------------------


More information about the Digitalmars-d mailing list