我正在编写这个函数,对于我设置result := -10
编译器的那一行,我会给出一个警告,说这个值永远不会被分配。我的逻辑有问题吗?
function combine (m1, m2 : string) : integer;
var
dash : integer;
distinct : integer;
i : integer;
begin
distinct := 0;
dash := -1;
for i := 0 to Length(m1)-1 do
begin
if m1[i] = m2[i] then
begin
distinct := distinct+1;
dash := i;
if distinct > 1 then
result:= -10;
end;
end;
result := dash;
end;