[Gambas-user] Collection as property?

Jussi Lahtinen jussi.lahtinen at gmail.com
Sun Nov 24 21:49:26 CET 2019


No, not forbid it, but control it. Example I may want to trigger some code
every time remove is used. And different code when add is used.


Jussi

On Sun, Nov 24, 2019 at 10:27 PM Tobias Boege <taboege at gmail.com> wrote:

> On Sun, 24 Nov 2019, Jussi Lahtinen wrote:
> > No, that is the easy part. I mean the _write. How to deal with .remove,
> > .add, etc?
> >
>
> By "dealing with it" I assumed you mean "forbid" it. What do you mean?
>
> If that's the case, just make another copy of the collection that is
> assigned to your property in _Write, and give out only copies of that
> internal copy. That way, nobody except the object itself can hold a
> reference to the collection inside your object and modifications from
> the outside are not possible.
>
> Regards,
> Tobi
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20191124/556e06fe/attachment.html>


More information about the User mailing list