Thread overview
Calling method on new instance of class
Jun 17, 2005
pmoore
Jun 17, 2005
xs0
Jun 17, 2005
pmoore
June 17, 2005
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
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
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