Setter chaining
DigitalDesigns
DigitalDesigns at gmail.com
Wed May 30 14:49:58 UTC 2018
Does it sound good?
class X
{
double x;
@property X foo(double y) { x = y; return this; }
@property X bar(double y) { x = y + 5; return this; }
}
void main()
{
X x = new X();
x.foo(3).bar(4);
}
It sort of emulates UFCS but I'm not sure if it's more trouble
than it's worth.
I figure it would be better than just returning void as it
provides the option to chain but not sure if it will come back to
bite me.
More information about the Digitalmars-d-learn
mailing list