Snippets

Stefan Glienke 94545: Untitled snippet

Updated by Stefan Glienke

File snippet.txt Modified

  • Ignore whitespace
  • Hide word diff
 
 {$APPTYPE CONSOLE}
 
+uses
+  SysUtils;
+
 type
   TFoo = class
   private
Created by Stefan Glienke

File snippet.txt Added

  • Ignore whitespace
  • Hide word diff
+program Project1;
+
+{$APPTYPE CONSOLE}
+
+type
+  TFoo = class
+  private
+    fCount: Integer;
+  public
+    property Count: Integer read fCount;
+  end;
+
+  TFooWithGetter = class
+  private
+    fCount: Integer;
+    function GetCount: Integer;
+  public
+    property Count: Integer read GetCount;
+  end;
+
+  TIntegerHelper = record helper for Integer
+    procedure Inc;
+  end;
+
+{ TIntegerHelper }
+
+procedure TIntegerHelper.Inc;
+begin
+  System.Inc(Self);
+end;
+
+{ TFooWithGetter }
+
+function TFooWithGetter.GetCount: Integer;
+begin
+  Result := fCount;
+end;
+
+var
+  f: TFoo;
+  f2: TFooWithGetter;
+begin
+  f := TFoo.Create;
+  f.Count.Inc;
+  Assert(f.Count = 1);
+
+  f2 := TFooWithGetter.Create;
+  f2.Count.Inc;
+  Assert(f2.Count = 1);
+end.
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.