<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>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                函數可以作為其它函數的參數進行傳遞,然后在其它函數內調用執行,一般稱之為回調。下面是一個將函數作為參數的簡單例子(function_parameter.go): ~~~ package main import ( "fmt" ) func main() { callback(1, Add) } func Add(a, b int) { fmt.Printf("The sum of %d and %d is: %d\n", a, b, a+b) } func callback(y int, f func(int, int)) { f(y, 2) // this becomes Add(1, 2) } ~~~ 輸出: ~~~ The sum of 1 and 2 is: 3 ~~~ 將函數作為參數的最好的例子是函數?`strings.IndexFunc()`: 該函數的簽名是?`func IndexFunc(s string, f func(c int) bool) int`,它的返回值是在函數?`f(c)`?返回 true、-1 或從未返回時的索引值。 例如?`strings.IndexFunc(line, unicode.IsSpace)`?就會返回?`line`?中第一個空白字符的索引值。當然,您也可以書寫自己的函數: ~~~ func IsAscii(c int) bool { if c > 255 { return false } return true } ~~~ 在第 14.10.1 節中,我們將會根據一個客戶端/服務端程序作為示例對這個用法進行深入討論。 ~~~ type binOp func(a, b int) int func run(op binOp, req *Request) { … } ~~~ **練習 6.7** 包?`strings`?中的?`Map`?函數和?`strings.IndexFunc()`?一樣都是非常好的使用例子。請學習它的源代碼并基于該函數書寫一個程序,要求將指定文本內的所有非 ASCII 字符替換成?`?`?或空格。您需要怎么做才能刪除這些字符呢?
                  <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>

                              哎呀哎呀视频在线观看