| Thread overview |
|---|
June 17, 2005 Calling method on new instance of class | ||||
|---|---|---|---|---|
| ||||
Hi,
Sorry if I'm labouring an old point but is there a reason why I can't do the following:
class A {
public this() {}
public void doSomething() {}
}
int main() {
new A().doSomething(); // can't do this
}
Thanks.
| ||||
June 17, 2005 Re: Calling method on new instance of class | ||||
|---|---|---|---|---|
| ||||
Posted in reply to pmoore | pmoore wrote:
> Hi,
>
> Sorry if I'm labouring an old point but is there a reason why I can't do the
> following:
>
> class A {
> public this() {}
> public void doSomething() {}
> }
>
> int main() {
> new A().doSomething(); // can't do this
> }
>
> Thanks.
You can, it's just a precedence problem:
(new A()).doSomething()
xs0
| |||
June 17, 2005 Re: Calling method on new instance of class | ||||
|---|---|---|---|---|
| ||||
Posted in reply to xs0 | Ah. Thank you. In article <d8ugjo$19e3$1@digitaldaemon.com>, xs0 says... > >pmoore wrote: >> Hi, >> >> Sorry if I'm labouring an old point but is there a reason why I can't do the following: >> >> class A { >> public this() {} >> public void doSomething() {} >> } >> >> int main() { >> new A().doSomething(); // can't do this >> } >> >> Thanks. > >You can, it's just a precedence problem: > >(new A()).doSomething() > > >xs0 | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply