<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之旅 廣告
                # Kotlin 中綴函數調用 > 原文: [https://www.programiz.com/kotlin-programming/infix-notation](https://www.programiz.com/kotlin-programming/infix-notation) #### 在本文中,您將學習使用`int`表示法在 Kotlin 中調用函數(借助示例)。 在學習如何創建具有中綴表示法的函數之前,讓我們探索兩個常用的中綴函數。 當您使用`||`和`&&`操作時,編譯器分別查找[或](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/or.html "Kotlin or function")和[和](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/and.html "Kotlin and function")函數,并在后臺進行調用。 這兩個函數支持中綴表示法。 * * * ### 示例:Kotlin `or`和`and`函數 ```kt fun main(args: Array<String>) { val a = true val b = false var result: Boolean result = a or b // a.or(b) println("result = $result") result = a and b // a.and(b) println("result = $result") } ``` 運行該程序時,輸出為: ```kt result = true result = false ``` 在上述程序中,使用`a or b`代替`a.or(b)`,并使用`a and b`代替`a.and(b)`。 這是可能的,因為這兩個函數都支持中綴表示法。 * * * ### 如何創建帶有中綴符號的函數? 您可以使用中綴符號在 Kotlin 中進行函數調用(如果該函數 * 是*成員函數*(或*擴展函數*)。 * 只有一個參數。 * 用`infix`關鍵字標記。 * * * ### 示例:帶中綴符號的用戶定義函數 ```kt class Structure() { infix fun createPyramid(rows: Int) { var k = 0 for (i in 1..rows) { k = 0 for (space in 1..rows-i) { print(" ") } while (k != 2*i-1) { print("* ") ++k } println() } } } fun main(args: Array<String>) { val p = Structure() p createPyramid 4 // p.createPyramid(4) } ``` 運行該程序時,輸出為: ```kt * * * * * * * * * * * * * * * * ``` 在此,`createPyramid()`是創建金字塔結構的中綴函數。 它是類`Structure`的成員函數,僅接受類型為`Int`的一個參數,并以關鍵字`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>

                              哎呀哎呀视频在线观看