Getters/setters generator
Eugene Wissner via Digitalmars-d-announce
digitalmars-d-announce at puremagic.com
Mon Jan 16 23:32:30 PST 2017
On Tuesday, 17 January 2017 at 07:06:05 UTC, Stefan Koch wrote:
> On Tuesday, 17 January 2017 at 06:26:35 UTC, Eugene Wissner
> wrote:
>> On Friday, 9 December 2016 at 18:53:55 UTC, Andrei
>> Alexandrescu wrote:
>>>
>>> Love it, and was toying with similar ideas too. One good
>>> extension is to add a predicate to the setter, which guards
>>> the assignment. -- Andrei
>>
>> What kind of predicate do you mean? Can you give an example
>> please?
>
> setValue(uint _under24)
> {
> assert(_under24 < 24);
> under24 = _under24;
> }
Ah, well thanks. I don't think it makes much sense since it would
be easier to write a complete setter if the user needs extra
checks. Accessors are there only for the generation of the
standard methods, that just get or set some object property.
More information about the Digitalmars-d-announce
mailing list