Precedence of 'new' vs '.'

Eldar Insafutdinov e.insafutdinov at gmail.com
Wed May 6 03:28:28 PDT 2009


Frank Benoit Wrote:

> In Java one can write:
> 
> new MyClass().run();
> 
> in D this does not compile, parenthesis are needed.
> 
> (new MyClass()).run();
> 
> But why is the D language designed like that?

Related problem:

string str = "qwe rty uio";
string[] arr = str.split(" "); // works

class A {
    string foo() { return "qwe rty uio"; }
}
A a = new A;
a.foo.split(" "); // doesn't work



More information about the Digitalmars-d mailing list