Delphi xe中 Exit 的新用法


本文整理自网络,侵删。

 
Delphi 2009 中 Exit 的新用法

Nick 描述了 Exit 在 Tiburon 中的新语法,看代码:

function foo(const I: Integer): string;
begin
    if I < 0 then Exit('负数'); 
    Result := '正数'; 
end
function foo(const I: Integer): string;
begin
    if I < 0 then begin Result := '负数'; Exit; end
    Result := '正数'; 
end
可以看到,Exit 的语言构造发生了变化,可以像函数一样带一个参数,参数类型就是 Result 的类型,退出函数的同时返回函数的值,与 Java、C# 等其它语言的 Return 功能一样。

相关阅读 >>

Delphi用代码实现注册ocx和dll

Delphi 字幕下载单元subdownload.pas

Delphi多线程程序示例

Delphi opendialog使用方法

Delphi unigui 路径

Delphi cxgrid 通过字段名取得列

Delphi stringgrid 实例2:1、获取 stringgrid 的行数、列数; 2、给单元赋值

Delphi xe2 - 实现无敌关机键

Delphi 的 webservice 的 cookie 操作

Delphi 组件值实现增减

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    暂无评论...