new X().bar(); is a syntax error?

BCS ao at pathlink.com
Thu Sep 20 10:02:43 PDT 2007


Reply to Ary,

> Compiling:
> 
> ---
> class X {
> void bar() {
> }
> }
> void foo() {
> new X().bar();
> }
> ---
> 
> gives me:
> main.d(7): found '.' when expecting ';' following 'statement'
> Is this a bug or is it the intended behaviour? I can do this in Java,
> C#, probably C++...
> 

I think it's not parsing how you want it, try this:

 (new X()).bar();




More information about the Digitalmars-d-learn mailing list