What the abstrac final class mean?
Jacob Carlborg
doob at me.com
Tue Aug 13 09:03:49 UTC 2019
On 2019-08-12 11:25, a11e99z wrote:
> its weird that next compiles in some weird form
>
> import std;
> static class A {
> static a() { "a".writeln; } // forgot return type
> }
Since you have specified an attribute on "a", the compiler can infer the
return type. In this case it's inferred to "void" since there is no
return statement.
It's not really the attribute that makes it possible for the compiler to
infer the return type, it probably can in most of the cases. It just
needs to be an attribute to satisfy the parser.
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list