if I = 0 then
    Result := Hint else
    Result := Copy(Hint, 1, I - 1);
这种写法到处都是,不可理解大虾们解释这样写的好处吧,谢谢

解决方案 »

  1.   

    呵呵
    我写代码全凭心情,
    这段代码有时会写成    if I = 0 then
          Result := Hint 
        else
          Result := Copy(Hint, 1, I - 1);有时会写成
       if I = 0 then  Result := Hint 
       else  Result := Copy(Hint, 1, I - 1);有时会写成
      if I = 0 then Result := Hint else Result := Copy(Hint, 1, I - 1);
      

  2.   

    我喜欢这样
    if .. then
      ..
    else
      ..
      

  3.   

    我好像喜欢这样的哦
      if I = 0 then
      begin
        Result := Hint;
      end
      else begin
        Result := Copy(Hint, 1, I - 1);
      end;只有一句我也不放过的
      

  4.   

    我喜欢这样
    if .. then
      ..
    else
      ..
      

  5.   

    if I = 0 then
               Result := Hint
             else
               Result := Copy(Hint, 1, I - 1);
      

  6.   

    如果一句我就不写begin..end,如果是多句就必须写begin..end
      

  7.   


      if I = 0 then
        Result := Hint else
        Result := Copy(Hint, 1, I - 1);这样很明了啊,如果I=0,那么就执行下一行,否则就再下一行。
    也就是说…………说什么呢,我不懂表达,
    但这些都没有必要强求自己去用何种书写规范,
    写多了自然就有自己的风格,即使现在的风格不是很好,
    但写的东东多了自然就能培养出良好的风格,这也叫“进化”吧!
      

  8.   

    我喜欢这样:
    if I = 0 then begin
      Result := Hint;
    end else begin
      Result := Copy(Hint, 1, I - 1);
    end;
      

  9.   

    统计工程量的时候更准确些吧.
    如果一个ELSE就占一行而ELSE后只有一句,你是不是在骗代码行数啊.
      

  10.   

    规范写法:
    begin 
      if I = 0 then
      begin
        Result := Hint;
      end
      else 
      begin
        Result := Copy(Hint, 1, I - 1);
      end;
    end;
      

  11.   

    为什么要被一些所谓的,没有必要的规定所约束呢?只能自己和别人能一眼看懂就行.if .. then
       ..
    else
       ..或
    if .. then
       .. else
       ..或
    if .. then
    begin
      ..
    end
    else
    begin
      ..
    end;...
    哪个写程序的不是一看就懂?
    没必要为这个而去费太多的心思, 只要自己写起来顺手就行.