@property method needs ()

Andre via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Nov 23 22:56:08 PST 2014


Hi,

in following example the @property method needs the ()
otherwise compiler error  for row 24 is thrown.
I cannot judge, whether the compiler behaves correct or not.

Kind regards
André

---

alias fnError = void delegate(string s);

interface IfSession
{
	@property fnError addError();
}

class Session: IfSession
{
	private fnError _addError;
	
	@property fnError addError()
	{
		return _addError;
	}
}

void main()
{
	auto session = new Session();
	session._addError = delegate(s){};
	
	session.addError()("test"); // Works
	session.addError("test"); // Does not work
}


More information about the Digitalmars-d-learn mailing list