<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. 前言 在定義函數的時候,如果只有一個參數,可以使用`infix`來進行簡化,如果定義函數的時候使用了這個關鍵字,那么點操作符以及參數的括號都可以不要,比如下面的案例。 # 2. 案例 ## 2.1 普通函數 還是以上一小節的為案例,定義一個可空的類擴展函數: ~~~ fun <T> T?.showInfo(default: String = "對象為空"): T?{ println(this ?: default) return this; } ~~~ 上面的方法,我們調用為: ~~~ fun main() { val a: String? = null a.showInfo() } ~~~ 而,我們可以使用更加簡潔的方式來嘗試簡化。 ## 2.2 infix函數 ~~~ infix fun <T> T?.showInfo(default: String): T?{ println(this ?: default) return this; } fun main() { val a: String? = null a showInfo "對象為空!" } ~~~ 結果: ``` 對象為空! ``` 注意到上面的函數調用看著確實簡潔,但是感覺也差不多,具體使用看自己習慣。且,在使用`infix`關鍵字之后,我們之前定義的默認參數就不再支持了。
                  <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>

                              哎呀哎呀视频在线观看