Default (keyword)

From RemObjects Software

Jump to: navigation, search

This is a Oxygene Keyword topic
Feel free to add your notes to this topic below.



Indexers, also known as Array Properties, are properties that can be treated like arrays:

Supplying the default attribute to an array index tells the compiler the implied property to be used if you do not supply one. Consider the following code:

x = class
  method GetItems(i: Integer): Integer;
  property Items[i: Integer]: Integer read GetItems ; default;
end;

Instead of referring to x.Items[5], you can now use the simpler x[5].

Multiple definitions of indexed properties (implicit overloading) are supported (with different array parameter types, of course) and so the following is valid also:

x = class
  method GetItems(i: Integer): String;
  method GetItems(s: String): String;
  property Items[i: Integer]: String read GetItems ; default;
  property Items[s: String]: String read GetItems ; default;
end;

Now x[5] and x['5'] can be used.


See Also


Product: RemObjects Oxygene (formerly known as Chrome)
Current version: 3.0 Previous Versions: 'Joyride' (2.0), 'Floorshow' (1.5), 'Adrenochrome' (1.0)

GlossaryKeywordsLanguage FeaturesPlatform FeaturesSamplesArticlesHow ToIssues

Personal tools