properties - Why not the set/get syntax?

John C johnch_atms at hotmail.com
Sat Apr 1 06:06:36 PST 2006


"Cris" <central_p at hotmail.com> wrote in message 
news:e0m0an$2sd1$1 at digitaldaemon.com...
> John C wrote:
>> "Cris" <central_p at hotmail.com> wrote in message 
>> news:e0lr0p$2n17$1 at digitaldaemon.com...
>>> How would you implement a  write only property?
>>
>> Implement only the setter.
>
> I mean a property that you can write but you cannot read. You can do that 
> in C#. Is it possible in D too?

As I said, implement only the setter.

struct Foo {
    int data_;
    void data(int value) { data_ = value; }
}

void main() {
    Foo foo;
    foo.data = 10;
    int a = foo.data; // function main.Foo.data (int) does not match 
argument types.
} 





More information about the Digitalmars-d mailing list