goto的使用(無條件跳轉)

用goto跳轉到必須在當前函數內定義的標籤
package main
import “fmt”
func main ( ) {
//break //break is not in a loop,switch,or select
//continue //continue is not in a loop
//goto可以用在任何地方,但是不能跨函數使用
fmt.Println(“111”)
goto End//goto是關鍵字,End是用於起的名字,叫做標籤
fmt.println(“222”)
End:
fmt.println(“333”)
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章