万一博客中提到了这个带参数的exit,原程序是: procedure TForm1.Button1Click(Sender: TObject); var s:string; begin s := func('ABC'); showmessage(s); s := func(''); showmessage(s); end; function Tform1.Func(str: string):string; begin if str='' then exit('空'); result := str + str; end; 执行结果是,第一个showmessage显示的是“ABCABC”,第二个显示的是“空”,原来这个exit只能用在function当中,他的意思是:退出执行流程,并将括号内的内容作为函数的返回结果。
带参数的exit
最新推荐文章于 2023-04-20 10:36:15 发布