呵呵 我写代码全凭心情, 这段代码有时会写成 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);
我喜欢这样 if .. then .. else ..
我好像喜欢这样的哦 if I = 0 then begin Result := Hint; end else begin Result := Copy(Hint, 1, I - 1); end;只有一句我也不放过的
我喜欢这样 if .. then .. else ..
if I = 0 then Result := Hint else Result := Copy(Hint, 1, I - 1);
如果一句我就不写begin..end,如果是多句就必须写begin..end
if I = 0 then Result := Hint else Result := Copy(Hint, 1, I - 1);这样很明了啊,如果I=0,那么就执行下一行,否则就再下一行。 也就是说…………说什么呢,我不懂表达, 但这些都没有必要强求自己去用何种书写规范, 写多了自然就有自己的风格,即使现在的风格不是很好, 但写的东东多了自然就能培养出良好的风格,这也叫“进化”吧!
我喜欢这样: if I = 0 then begin Result := Hint; end else begin Result := Copy(Hint, 1, I - 1); end;
规范写法: begin if I = 0 then begin Result := Hint; end else begin Result := Copy(Hint, 1, I - 1); end; end;
为什么要被一些所谓的,没有必要的规定所约束呢?只能自己和别人能一眼看懂就行.if .. then .. else ..或 if .. then .. else ..或 if .. then begin .. end else begin .. end;... 哪个写程序的不是一看就懂? 没必要为这个而去费太多的心思, 只要自己写起来顺手就行.
我写代码全凭心情,
这段代码有时会写成 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);
if .. then
..
else
..
if I = 0 then
begin
Result := Hint;
end
else begin
Result := Copy(Hint, 1, I - 1);
end;只有一句我也不放过的
if .. then
..
else
..
Result := Hint
else
Result := Copy(Hint, 1, I - 1);
if I = 0 then
Result := Hint else
Result := Copy(Hint, 1, I - 1);这样很明了啊,如果I=0,那么就执行下一行,否则就再下一行。
也就是说…………说什么呢,我不懂表达,
但这些都没有必要强求自己去用何种书写规范,
写多了自然就有自己的风格,即使现在的风格不是很好,
但写的东东多了自然就能培养出良好的风格,这也叫“进化”吧!
if I = 0 then begin
Result := Hint;
end else begin
Result := Copy(Hint, 1, I - 1);
end;
如果一个ELSE就占一行而ELSE后只有一句,你是不是在骗代码行数啊.
begin
if I = 0 then
begin
Result := Hint;
end
else
begin
Result := Copy(Hint, 1, I - 1);
end;
end;
..
else
..或
if .. then
.. else
..或
if .. then
begin
..
end
else
begin
..
end;...
哪个写程序的不是一看就懂?
没必要为这个而去费太多的心思, 只要自己写起来顺手就行.