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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                >[warning] **定義**:靜態擴展 一個靜態擴展允許偽裝擴展存在的類型而不用修改它們的源碼。在Haxe中這是通過聲明一個靜態方法,第一個參數是要擴展的類型,然后帶入定義類到上下文中就可以使用。 >[warning] De?nition: Static Extension A static extension allows pseudo-extending existing types without modifying their source. In Haxe this is achieved by declaring a static method with a ?rst argument of the extending type and then bringing the de?ning class into context through using. 靜態擴展是一個強大的工具,使得可以不用實際修改就對類型進行擴展。下面的示例展示用法: > Static extensions can be a powerful tool which allows augmenting types without actually changing them. The following example demonstrates the usage: ~~~ using Main.IntExtender; class IntExtender { static public function triple(i:Int) { return i * 3; } } class Main { static public function main() { trace(12.triple()); } } ~~~ 顯然,Int并沒有原生提供一個 triple 方法,然而這個程序編譯并輸出預期的 36 。這是因為調用 12.triple() 是轉換到 IntExtender.triple(12) 。這有三個要求: > Clearly,Int does not natively provide a triple method,yet this program compiles and outputs 36 as expected. This is because the call to 12.triple() is transformed into IntExtender.triple(12). There are three requirements for this: 1. 字面的值12和第一個參數都是已知的Int類型 2. IntExtender類通過 using Main.IntExtender 帶入到上下文 3. Int本身沒有 triple字段(如果它有,那個字段會優先于靜態擴展) > 1. Both the literal 12 and the ?rst argument of triple are known to be of type Int. > 2. The class IntExtender is brought into context through using Main.IntExtender. > 3. Int does not havea triple ?eld by itself (if it had,that ?eld would take priority over the static extension). 靜態擴展通常認為是語法糖,事實也是如此,但是值得注意的是,它們可以對代碼可讀性有一個戲劇性影響:替代嵌套的調用形式如f1(f2(f3(f4(x)))),使用鏈式調用形式如x.f4().f3().f2().f1() 。 > Static extensions are usually considered syntactic sugar and indeed they are, but it is worth noting that they can have a dramatic effect on code readability: Instead of nested calls in the form of f1(f2(f3(f4(x)))), chained calls in the form of x.f4().f3().f2().f1() can be used. 遵守前面講述過的解析順序(第3.7.3節),多個使用的表達式從底部到頭部檢查,而在每個模塊的類型以及在每個類型中的字段從頭至尾檢查。使用一個模塊(而不是一個模塊中的特定類型,查看模塊和路徑(第3.7節))作為靜態擴展會把所有它的類型帶入上下文中。 > Following the rules previously described in Resolution Order(Section3.7.3),multiple using expressions are checked from bottom to top, with the types within each module as well as the ?elds within each type being checked from top to bottom. Using a module (as opposed to a speci?c type of a module, see Modules and Paths (Section 3.7)) as static extension brings all its types into context.
                  <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>

                              哎呀哎呀视频在线观看