unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls;type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); end;var Form1: TForm1;implementation{$R *.dfm}function fun(str: string): string;begin if str = '' then Exit('空'); {Delphi 2009 支持} Result := str + str;end;procedure TForm1.Button1Click(Sender: TObject);var s: string;begin s := fun('ABC'); ShowMessage(s); {ABCABC} s := fun(''); ShowMessage(s); {空}end;end.