Why does this compile (method in class without return type)

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 3 05:50:19 PDT 2017


On Wednesday, 3 May 2017 at 07:37:31 UTC, Jacob Carlborg wrote:
> It might be by accident but I think the compiler is inferring 
> the return type. Just as "auto" is not necessary to infer the 
> type of a variable if there's another attribute:

No accident there, the spec says any storage class will do:
http://dlang.org/spec/function.html#auto-functions

"An auto function is declared without a return type. If it does 
not already have a storage class, use the auto storage class. "


More information about the Digitalmars-d-learn mailing list