| Thread overview | |||||
|---|---|---|---|---|---|
|
June 14, 2002 Return value from constructor | ||||
|---|---|---|---|---|
| ||||
Hi,
It seems that constructors has a return type. The class Good below compiles, but Bad does not.:
/*
class Bad
{
this()
{
return; // causes "return value expected"
}
}
*/
class Good
{
this()
{
return this; // compiles fine
}
}
It can't be right, can it?
Regards,
Martin M. Pedersen
| ||||
June 15, 2002 Re: Return value from constructor | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Martin M. Pedersen | I'll have to think about that one! "Martin M. Pedersen" <mmp@www.moeller-pedersen.dk> wrote in message news:aedpad$rma$1@digitaldaemon.com... > Hi, > > It seems that constructors has a return type. The class Good below compiles, > but Bad does not.: > > /* > class Bad > { > this() > { > return; // causes "return value expected" > } > } > */ > > class Good > { > this() > { > return this; // compiles fine > } > } > > > It can't be right, can it? > > Regards, > Martin M. Pedersen > > > > > > | |||
June 15, 2002 Re: Return value from constructor | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Walter | Could be an interesting way to do a kind of "operator new". I've toyed with that and so far nothing has turned up that looked good. But it has potential. Sean "Walter" <walter@digitalmars.com> wrote in message news:aeelqn$1mk7$1@digitaldaemon.com... > I'll have to think about that one! > > "Martin M. Pedersen" <mmp@www.moeller-pedersen.dk> wrote in message news:aedpad$rma$1@digitaldaemon.com... > > Hi, > > > > It seems that constructors has a return type. The class Good below > compiles, > > but Bad does not.: > > > > /* > > class Bad > > { > > this() > > { > > return; // causes "return value expected" > > } > > } > > */ > > > > class Good > > { > > this() > > { > > return this; // compiles fine > > } > > } > > > > > > It can't be right, can it? > > > > Regards, > > Martin M. Pedersen | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply