<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國際加速解決方案。 廣告
                整個文檔中都會看到類型推斷的效果,并且在后面也是非常重要的部分。一個例子可以展示類型推斷: > The effects of type inference have been seen throughout this document and will continue to be important. A simple example shows type inference at work: ~~~ class Main { public static function main() { var x = null; $type(x); // Unknown<0> x = "foo"; $type(x); // String } } ~~~ 特殊的構造 $type 前面有提到過,在簡單的介紹函數類型(第2.6節)的部分,現在正式介紹它: > The special construct $type was previously mentioned in order to simplify the explanation of the Function Type (Section 2.6) type, so let us now introduce it of?cially: **$type** >[warning] 構造:$type $type 是一個編譯時機制,可以像函數一樣調用,接受一個單獨的參數。編譯器執行參數表達式并輸出表達式的類型。 >[warning] Construct: $type $type is a compile-time mechanism being called like a function,with a single argument. The compiler evaluates the argument expression and then outputs the type of that expression. 在上面的例子中,第一個 $type 輸出 Unknow<0> 。這是一個 單形(第2.9節),一個還不知道的類型。下一行 x="foo" 賦值一個字符串字面量到 x ,使得 單形合一(第3.5節)為 String 。我們然后可以看到x的類型實際上被改變為 String 。 > In the example above,the first $type prints Unknown<0>. This is a monomorph(2.9),a type that is not yet known. The next line x = "foo" assigns a String literal to x, which causes the uni?cation (3.5) of the monomorph with String. We then see that the type of x indeed has changed to String. 每當一個不同于 Dynamic(第2.7節)的類型被使用一個單形統一時,那個單形則變為該類型:它改變為那個類型。因此它之后就不能變形為一個不同的類型,一個屬性在它的名字的mono部分表示。 > Whenever a type other than Dynamic(Section2.7) is uni?ed with a monomorph,that monomorph becomes that type: it morphs into that type. Therefore it cannot morph into a different type afterwards, a property expressed in the mono part of its name. 遵循合一的規則,類型推斷可以在復合類型中出現: > Following the rules of uni?cation, type inference can occur in compound types: ~~~ class Main { public static function main() { var x = []; $type(x); // Array<Unknown<0>> x.push("foo"); $type(x); // Array<String> } } ~~~ 變量 x 是首先初始化為一個空的數組。此時我們可以看出x的類型是一個數組,但是我們還不知道數組元素的類型。必然,x的類型是 Array<Unknow<0>>。只有在推送一個字符串到數組后我們才知道類型變為 Array<String>。 > Variable x is ?rst initialized to an empty Array. At this point we can tell that the type of x is an array, but we do not yet know the type of the array elements. Consequentially, the type of x is Array<Unknown<0>>. It is only after pushing a String onto the array that we know the type to be Array<String>.
                  <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>

                              哎呀哎呀视频在线观看