property returning a reference vs returning a value
Jonathan M Davis
jmdavisProg at gmx.com
Wed Jun 20 00:28:57 PDT 2012
On Wednesday, June 20, 2012 09:03:44 cal wrote:
> On Wednesday, 20 June 2012 at 06:34:06 UTC, Jonathan M Davis
>
> wrote:
> > You can't overload on return type. The parameters need to be
> > different, or the functions are going to conflict.
>
> Ah, that explains it, thanks. I find ref properties useful for
> making a member variable behave like it is public, but allowing
> the struct to be aware when it's being accessed, at least that's
> what I use it for.
You know when it's gotten, but you don't know when it's set (just that it was
gotten when they set it). If that's useful to you, then fine, but be aware that
you lose control of the setting that way. Personally, I'd just declare a
setter rather than return ref from a getter.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list