On Fri, 16 Jun 2006 08:03:19 +0200
Micha Nelissen <[EMAIL PROTECTED]> wrote:
> Tony Pelton wrote:
> >> Classes with indexed properties work and look like associative arrays.
> >
> > how do index'ed properties help you store objects by a key ?
>
> Something like:
>
> type
> THash = class(TObject)
> protected
> function GetItem(AKey: string): string;
> procedure SetItem(AKey, NewValue): string;
> public
> property Items[AKey: string]: string read GetItem
> write SetItem default;
> end;
>
> The 'default' keyword makes the array usable "on the instance":
>
> var
> Hash: THash;
> begin
> Hash := ...
> Hash['sun'] := 'yellow';
> Hash['sky'] := 'blue';
> { etc ... }
> end.
See lcl/stringhashlist.pas
Mattias
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives