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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                存取器方法的可見性不會影響屬性的可得到與否。也就是說,如果一個屬性是 public 的而且定義為有一個 getter ,不管如何 那個getter 會自我定義為private。 > Visibility of accessor methods has no effect on the accessibility of its property. That is, if a property is public and de?ned to have a getter, that getter may me de?ned as private regardless. getter 和setter 可以訪問它們的數據存儲的物理字段。編譯器確保這類的字段訪問,如果從存取器方法本身做出,不會通過存取器方法,從而避免無限遞歸: > Both getter and setter may access their physical ?eld for data storage. The compiler ensures that this kind of ?eld access does not go through the accessor method if made from within the accessor method itself, thus avoiding in?nite recursion: ~~~ class Main { public var x(default, set):Int; function set_x(newX) { return x = newX; } static public function main() {} } ~~~ 然而,編譯器只有如果至少一個訪問標識符是default或者null的時候假設一個物理字段存在。 > However, the compiler assumes that a physical ?eld exists only if at least one of the access identi?ers is default or null. **物理字段** >[warning] 定義:物理字段 > 一個字段在如下任何一個情況被認為是物理的: > 一個變量(第4.1節) > 一個屬性(第4.2節)帶有 讀取訪問或者寫入訪問標識符為default或者null > 一個屬性帶有 :isVar 元數據(第6.9節) >[warning] De?nition: Physical ?eld A ?eld is considered to be physical if it is either >[warning] * a variable (4.1) >[warning] * a property (4.2) with the read-access or write-access identi?er being default or null >[warning] * a property (4.2) with :isVar metadata (6.9) 如果不是這種情況,從一個存取器內部訪問字段導致一個編譯錯誤: > If this is not the case,access to the ?eld from within an accessor method causes a compilation error: ~~~ class Main { // This field cannot be accessed because it is not a real variable public var x(get, set):Int; function get_x() { return x; } function set_x(x) { return this.x = x; } static public function main() {} } ~~~ 如果一個物理字段是真實準備的,它可以通過歸于討論的字段被強制與 :isVar 元數據。 > If a physical ?eld is indeed intended,it can be forced by attributing the ?eld in question with the :isVar metadata (6.9): ~~~ class Main { // @isVar forces the field to be physical allowing the program to compile. @:isVar public var x(get, set):Int; function get_x() { return x; } function set_x(x) { return this.x = x; } static public function main() {} } ~~~ >[warning] **花絮**:屬性的 setter 類型 并不少見新的Haxe用戶被setter的類型需要是T->T而不是看起來更自然的T->Void類型驚訝到。畢竟,為什么一個setter需要返回些什么呢?基本原理是,我們仍然想要可以是i用字段分配使用setter為右手表達式。給定一個鏈如 x=y=1 ,執行為 x=(y=1) 。為了賦值y=1的結果到x,形式必須有一個值。如果 y 有一個setter 返回Void,這是不可能的。 >[warning] Trivia: Property setter type It is not uncommon for new Haxe users to be surprised by the type of a setter being required to be T->T instead of the seemingly more natural T->Void. After all, why would a setter have to return something? The rationale is that we still want to be able to use ?eld assignments using setters as rightside expressions. Given a chain like x = y = 1, it is evaluated as x = (y = 1). In order to assign the result of y = 1 to x, the former must have a value. If y had a setter returning Void, this would not be possible.
                  <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>

                              哎呀哎呀视频在线观看