Array methods lazarus / 62-General ---------------------------------------------------------------------- riwu · 2015-12-26 09:12 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  PointArr = array of TPoint;function PointArr.contains(x: TPoint): Boolean;Is there a simple way to create routines that operates on arrays? One way i know of is to declare PointArr as 'object', which allows type routines, but i wouldn't be able to use built-in array routines like Length(), SetLength(), [] property etc, so i would have to keep track of the length and implement these custom methods myself which makes it unnecessarily complicated, but is that the only way to achieve what i want? ---------------------------------------------------------------------- Leledumbo · 2015-12-26 09:48 http://wiki.lazarus.freepascal.org/Helper_types ---------------------------------------------------------------------- howardpc · 2015-12-26 10:38 Note that if you have FPC 3.0 it is now possible to write constructs like this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  {$ModeSwitch typehelpers}type  PointArr = array of TPoint;    PointArrayHelper = type helper for PointArr    function Contains(x: TPoint): Boolean;  end;    ...    function PointArrayHelper.Contains(x: TPoint): Boolean;var  p: TPoint;begin  Result:=False;  if (Length(Self) = 0) then    Exit  else begin    for p in Self do      if (p.x = x.x) and (p.y = x.y) then        Exit(True);  end;end;  var  pa: PointArray;    ...    if pa.Contains(Point(0, 3)) then    ...