goto 语句


procedure TForm1.Button1Click(Sender: TObject);

var

  x: Integer;

  label n1,n2,n3,4;  //goto的标签可以是标识符, 也可以是0..9999的数字

begin

  x := 0;

  goto n3;

  n1: x := x+1;

  n2: x := x+2;

  n3: x := x+3;

  4:  x := x+4;

  ShowMessage(IntToStr(x));  //返回7而不是10

end;


 
   

你可能感兴趣的:(Go)