On Thursday, 20 September 2012 at 14:31:55 UTC, Will Rubin wrote:
Just a _write_ property:

struct Bleem {
  int _value;
public:
  //@property int value() { return _value; }
@property int value(int newValue) { return _value = newValue; }
}

void main() {
  auto bleem = Bleem();
  writeln("Result: ", bleem.value = 9);
}

Application Output
Result: 9

Off the top of my head (C#, Delphi, Python) have them return void. Maybe it's not so uncommon though.

On Thursday, 20 September 2012 at 13:57:54 UTC, monarch_dodra wrote:
A bit interesting to see I can declare a write property that returns a value rather than void.

Why would a property return void. If anything, it would return a non void:

auto a = someRange.front;

front is a property that returns a value.

It is usually more common to just have a read property that returns a reference, which can be written to.

If the property needs an explicit write version, then usually, returning a value is considered "costly".

But the point is you can do whatever you want anyways.

Reply via email to