if then else 的特殊简写方法

 我们经常遇到类似:

 

var

   a,b:Integer

begin

   if (条件) then

     Result := a

  else 

    Result := b;

nd;

 

可以简写为

  Result := iif(条件,a,b);

 

iif 在单元IdGlobal中,支持多种数据类型

 

--------------------------------------------------------------------------------------------------------

另外: strUtils.ifThen; Math.ifThen 两个函数可以实现 string和integer类型的iif.

--------------------------------------------------------------------------------------------------------

你可能感兴趣的:(if then else 的特殊简写方法)