<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國際加速解決方案。 廣告
                大多數時候,類型自己被推斷,然后可以被統一為一個預期的類型。然而在一些地方,一個預期的類型可能被用來影響推斷。然后我們討論自上而下的推斷。 > Most of the time,types are inferred on their own and may then be uni?ed with an expected type. In a few places,however,an expected type may be used to in?uence inference. We then speak of top-down inference. **預期類型** >[warning] 定義:預期類型 預期的類型在表達式的類型在它被類型化之前已知的時候出現,例如,因為表達式被看作一個函數調用。它們可以影響這個表達式的類型化,通過所謂的自上而下推斷(第3.6.1節)。 >[warning] De?nition: Expected Type Expected types occur when the type of an expression is known before that expression has been typed, e.g. because the expression is argument to a function call. They can in?uence typing of that expression through what is called top-down inference (3.6.1). 一個很好的例子是混合類型的數組。如在 Dynamic(第2.7節)中提到的,編譯器拒絕[1,"foo"]因為它不能確定元素的類型。使用自上而下的推斷,這個問題可以被克服: > A good example are arrays of mixed types. As mentioned in Dynamic (Section 2.7), the compiler refuses [1, "foo"] because it cannot determine an element type. Employing top-down inference, this can be overcome: ~~~ class Main { static public function main() { var a:Array<Dynamic> = [1, "foo"]; } } ~~~ 這里,編譯器知道當類型化 [1,"foo"],預期的類型是 Array<Dynamic>,所以元素類型是 Dynamic 。和通常的合一行為不同,編譯器會嘗試(并失敗)去確定一個通用類型(第3.5.5節),個別的元素不利于類型化會被統一為 Dynamic。 > Here,the compiler knows while typing [1, "foo"] that the expected type is Array<Dynamic>, so the element type is Dynamic. Instead of the usual uni?cation behavior where the compiler would attempt (and fail) to determine a common base type (3.5.5), the individual elements are typed against and uni?ed with Dynamic. 在構建泛型類型參數(第3.3.1節)被引入的時候,我們看到了另一個自上而下推斷的有趣用法 > We have seen another interesting use of top-down inference when construction of generic type parameters (3.3.1) was introduced: ~~~ typedef Constructible = { public function new(s:String):Void; } class Main { static public function main() { var s:String = make(); var t:haxe.Template = make(); } @:generic static function make<T:Constructible>():T { return new T("foo"); } } ~~~ 顯式的類型 String是 被haxe.Template在這里使用的,來確定make的返回類型。這是因為方法調用為 make(),所以我們知道返回類型會分配到變量。利用這個信息,可以分別綁定 unknown 類型 T到 String和 haxe.Template 。 > The explicit types String and haxe.Template are used here to determine the return type of make. This works because the method is invoked as make(),so we know the return type will be assigned to the variables. Utilizing this information, it is possible to bind the unknown type T to String and haxe.Template respectively.
                  <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>

                              哎呀哎呀视频在线观看