Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
38
Task/String-prepend/Delphi/string-prepend.delphi
Normal file
38
Task/String-prepend/Delphi/string-prepend.delphi
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
program String_preappend;
|
||||
|
||||
{$APPTYPE CONSOLE}
|
||||
|
||||
uses
|
||||
System.SysUtils;
|
||||
|
||||
type
|
||||
TStringHelper = record helper for string
|
||||
procedure Preappend(str: string);
|
||||
end;
|
||||
|
||||
{ TStringHelper }
|
||||
|
||||
procedure TStringHelper.Preappend(str: string);
|
||||
begin
|
||||
Self := str + self;
|
||||
end;
|
||||
|
||||
begin
|
||||
var h: string;
|
||||
|
||||
// with + operator
|
||||
h := 'World';
|
||||
h := 'Hello ' + h;
|
||||
writeln(h);
|
||||
|
||||
// with a function concat
|
||||
h := 'World';
|
||||
h := concat('Hello ', h);
|
||||
writeln(h);
|
||||
|
||||
// with helper
|
||||
h := 'World';
|
||||
h.Preappend('Hello ');
|
||||
writeln(h);
|
||||
readln;
|
||||
end.
|
||||
Loading…
Add table
Add a link
Reference in a new issue