Skip to Main Content
Mastering Delphi Programming: A Complete Reference Guide
book

Mastering Delphi Programming: A Complete Reference Guide

by Primož Gabrijelčič
November 2019
Beginner to intermediate content levelBeginner to intermediate
674 pages
15h
English
Packt Publishing
Content preview from Mastering Delphi Programming: A Complete Reference Guide

Delphi idioms – Assign and AssignTo

The Delphi RTL class TPersistent, which is implemented in unit System.Classes, defines two methods: Assign and AssignTo. Relevant parts of this class are shown next:

type  TPersistent = class(TObject)  protected    procedure AssignTo(Dest: TPersistent); virtual;  public    procedure Assign(Source: TPersistent); virtual;  end;procedure TPersistent.Assign(Source: TPersistent);begin  if Source <> nil then Source.AssignTo(Self) else AssignError(nil);end;procedure TPersistent.AssignTo(Dest: TPersistent);begin  Dest.AssignError(Self);end;

Any descendent of the TPersistent class can override any or both of these methods. When you know how to copy data from some type into the object, you override Assign. When you know how ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Delphi GUI Programming with FireMonkey

Delphi GUI Programming with FireMonkey

Andrea Magni
Delphi Cookbook - Third Edition

Delphi Cookbook - Third Edition

Daniele Spinetti, Daniele Teti

Publisher Resources

ISBN: 9781838989118Other