<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 控制語句 1. if條件判斷 > if條件判斷:在布爾表達式里面可以定義變量,并行賦值.變量的作用域只能作用在代碼塊里面. ```go // 格式: if <布爾表達式>{ 語句塊 }else if <布爾表達式>{ 語句塊 }else{ 語句塊 } // 定義i=5 輸出5,下面一句會編譯出錯 if i:=5;i<10{ print(i) } print(i) ``` 2. 循環控制 > go可以使用for完成所有的循環操作,變量的作用域只能作用在代碼塊里面 ```go //經典for循環結構 for i:=1;i<100;i++{ print(i) } //單條件(while式)for循環結構 for true{ print("進入死循環") } // 無條件式 for { print("hello") } ``` 3. switch語句 > switch不需要使用break,自動進行跳出,若需要連續條件選擇,使用fallthrough。 ```go // 常規操作 i := 3 switch i{ case 1: print(1) case 2: print(2) case 3: print(3) default: print(4) } // 在表達式中定義變量 switch i=3; { case i==1: print(1) case i==2: print(2) case i==3: print(3) default: print(4) } // 使用fallthrough 輸出2 3 i := 2 switch i{ case 1: print(1) case 2: print(2) fallthrough case 3: print(3) default: print(4) } ``` 4. 跳轉語句 > goto break continue 三者均可以執行跳轉。 > goto用于調整執行位置。使用時,注意標簽的位置 > break用于循環語句中跳出循環,并開始執行循環之后的語句 > continue不是跳出循環,而是跳過當前循環執行下一次循環語句,一般用于for 循環中,觸發for增量語句的執行。 ```go //goto操作 這里輸出 你好,這里是跳轉 START: print("你好,這里是跳轉") os.Exit(1) for i:=1; i<3;i++ { goto START } print("這里是測試是否跳轉") // break操作 輸出 跳出了循環start START: for i:=1;i<=2 ;i++ { break START } print("跳出了循環start") //continue操作 輸出 2 4 6 8 for i:=1;i<10 ;i++ { if(i%2!=0){ continue } print(i) } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看