<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之旅 廣告
                # This 表達式 [TOC] 為了表示**當前的接收者對象**我們使用 *this*表達式: * 在[類](http://www.kotlincn.net/docs/reference/classes.html#%E7%BB%A7%E6%89%BF)的成員中,*this*指的是該類的當前對象。 * 在[擴展函數](http://www.kotlincn.net/docs/reference/extensions.html)或者[帶有接收者的函數字面值](http://www.kotlincn.net/docs/reference/lambdas.html#%E5%B8%A6%E6%9C%89%E6%8E%A5%E6%94%B6%E8%80%85%E7%9A%84%E5%87%BD%E6%95%B0%E5%AD%97%E9%9D%A2%E5%80%BC)中,*this* 表示在點左側傳遞的 _接收者_ 參數。 如果 *this* 沒有限定符,它指的是最內層的包含它的作用域。要引用其他作用域中的 *this*,請使用 _標簽限定符_: ## 限定的 *this* 要訪問來自外部作用域的*this*(一個類或者擴展函數,或者帶標簽的帶有接收者的函數字面值)我們使用`this@label`,其中 `@label` 是一個代指 *this*來源的標簽: ```kotlin class A { // 隱式標簽 @A inner class B { // 隱式標簽 @B fun Int.foo() { // 隱式標簽 @foo val a = this@A // A 的 this val b = this@B // B 的 this val c = this // foo() 的接收者,一個 Int val c1 = this@foo // foo() 的接收者,一個 Int val funLit = lambda@ fun String.() { val d = this // funLit 的接收者 } val funLit2 = { s: String -> // foo() 的接收者,因為它包含的 lambda 表達式 // 沒有任何接收者 val d1 = this } } } } ``` 訪問來自外部作用域的this(類,擴展函數,帶接收者的字面函數),我們使用this@label,其中 @label 是一個代指 this 來源的標簽: 示例: ``` fun main(args: Array<String>) { A().B().p() } class A { //隱式標簽 @A inner class B { //隱式標簽 @B fun p(){ println(this)//輸出A$B@279f2327,this代指[B類對象] 666.foo() } fun Int.foo() { //隱式標簽 @foo println(this@A)//輸出A@2ff4acd0, this代指[A類對象] println(this@B)//輸出A$B@279f2327, this代指[B類對象] println(this)//輸出666, this代指[foo函數接收者Int類對象] println(this@foo)//輸出666, this@foo代指[foo函數接收者Int類對象] val funLit = fun String.() { //this代指[funLit函數接收者String類對象] println(this) //輸出lit } "lit".funLit() val funLit2 = { s: String -> //該函數沒有接收者,故this代指[foo函數接收者Int類對象] println(this) //輸出666 } funLit2("lit2") } } } ```
                  <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>

                              哎呀哎呀视频在线观看