<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智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                變量下面,屬性是第二個選項來處理類中的數據。然而不像變量,它們提供更多的控制哪種類型的字段訪問被允許,和它如何被生成。通常用處包括: > Next to variables (4.1), properties are the second option for dealing with data on a class. Unlike variables however, they offer more control of which kind of ?eld access should be allowed and how it should be generated. Common use cases include: * 有一個可以被從任何地方讀取,但是只能被從定義類寫入的字段 * 有一個調用一個getter方法獲得讀權限的字段 * 有一個調用一個setter方法獲得寫入權限的字段 > * Have a ?eld which can be read from anywhere,but only be written from within the de?ning class. > * Have a ?eld which invokes a getter-method upon read-access. > * Have a ?eld which invokes a setter-method upon write-access. 當處理屬性時,重要的是理解兩種類型的訪問: > When dealing with properties, it is important to understand the two kinds of access: >[warning] 定義:讀取訪問 > 一個字段的讀取訪問發生在右手字段訪問表達式(第5.7節)使用時。包括通過 obj.field() 形式調用來訪問授權讀取的字段。 > 定義:寫入訪問 > 一個字段的寫入訪問發生在一個字段訪問表達式被以obj.field=value格式賦一個值的時候。也可能和讀取訪問聯合出現,對于特別的賦值操作符如 += ,表達式形如 obj.field += value 。 >[warning] De?nition: Read Access A read access to a ?eld occurs when a right-hand side ?eld access expression (5.7) is used. This includes calls in the form of obj.field(), where field is accessed to be read. >[warning] De?nition: Write Access A write access to a ?eld occurs when a ?eld access expression (5.7) is assigned a value in the form of obj.field = value. It may also occur in combination with read access (4.2) for special assignment operators such as += in expressions like obj.field += value. 讀取訪問和寫入訪問直接反映在語法形式,如下面的例子: > Read access and write access are directly re?ected in the syntax, as the following example shows: ~~~ class Main { public var x(default, null):Int; static public function main() { } } ~~~ 多數情況,和變量的語法類似,實際上適用同樣的規則。屬性被識別,通過 > For the most part, the syntax is similar to variable syntax, and the same rules indeed apply. Properties are identi?ed by * 字段名后開口的括號 ( , * 后面跟一個特定的訪問標識符(這里是 default), * 逗號,隔開 * 另一個特殊的訪問標識符(這里是null), * 和一個閉口的括號 ) > * the opening parenthesis ( after the ?eld name, > * followed by a special access identi?er (here: default), > * with a comma , separating > * another special access identi?er (here: null) > * before a closing parenthesis ). 訪問標識符定義當字段被讀取(第一個標識符)的行為,和寫入的行為(第二個標識符)。接受的值為: > The access identi?ers de?ne the behavior when the ?eld is read (?rst identi?er) and written (second identi?er). The accepted values are: **default**:如果字段有公開的可見性,則允許普通的字段訪問,否則等于 null 訪問。 **null**:只允許從定義的類中訪問。 **get/set**:訪問被生成為一個存取器方法。編譯器確保存取器可用。 **dynamic**:類似get/set訪問,但是不驗證存取器字段的存在。 **never**:不允許訪問 > **default**: Allows normal ?eld access if the ?eld has public visibility, otherwise equal to null access. > **null**: Allows access only from within the de?ning class. > **get/set**: Access is generated as a call to an accessor method. The compiler ensures that the accessor is available. > **dynamic**: Like get/set access, but does not verify the existence of the accessor ?eld. > **never**: Allows no access at all. **存取器方法** >[warning] 定義:存取器方法 一個T類型名為 filed 的字段的一個存取器方法(或者簡稱為存取器)是一個Void->T類型名為 get_field 的 getter,或者T->T類型名為 set_field的setter。 >[warning] De?nition: Accessor method An accessor method (or short accessor) for a ?eld named field of type T is a getter named get_field of type Void->T or a setter named set_field of type T->T. **存取器名稱** >[warning] 花絮:存取器名稱 在Haxe 2中,任意的標識符允許作為訪問標識符,可以使定制的存取器方法名是被認可的。這使得部分實現非常難以處理。特別是,Reflect.getProperty() 和 Reflect.setProterty() 必須假定任何名稱可能被使用,需要目標生成器生成元信息和執行查找。我們不允許這些標識符,而使用 get_ 和 set_ 命名約定,大大簡化了實現。這是Haxe2 和Haxe 3之間一個阻斷式的變更。 >[warning] Trivia: Accessor names In Haxe 2, arbitrary identi?ers were allowed as access identi?ers and would lead to custom accessor method names to be admitted. This made parts of the implementation quite tricky todealwith. In particular,Reflect.getProperty() and Reflect.setProperty() had to assume that any name could have been used, requiring the target generators to generate meta-information and perform lookups. We disallowed these identi?ers and went for the get_ and set_ naming convention which greatly simpli?ed implementation. This was one of the breaking changes between Haxe 2 and 3.
                  <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>

                              哎呀哎呀视频在线观看