I study Delphi, read a book by Marco Cant, and it is super complete. This is very clear, but I doubt the keyword self . I already have experience with OOP, and I have the basics of this. My question is very simple. Can I compare the keyword self (Delphi) with the keyword this (Java)?
When I read the book on self used internal records, I realized something like self : Delphi = this : Java . Take a look at the code I created for the test:
type TMarioKart = packed record Character: String; Kart: String; Tires: String; Speed: double; Competitive: boolean; private air-speed: integer; ground-speed: integer; water-speed: integer; public constructor Create(Character: string); function ShowStats(a: TMarioKart):string; overload; function ShowStats(a: TMarioKart; b: TMarioKart): string; overload; end;
I'm going to cut off most of the code, I just show the constructor here:
constructor TMarioKart.Create(Character: string); begin self.Character := Character; end;
Using the self keyword here, I am referring to the record character, not the character passed in in the method. Is it right to use yourself? Could this be Java's brother this ?
delphi self
Alberto miola
source share