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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                >[warning] 定義:泛型類型參數 如果它的包含類或者方法是泛型,則一個類型參數被認為是泛型。 >[warning] De?nition: Generic Type Parameter A type parameter is said to be generic if its containing class or method is generic. 不可能構建一般的類型參數,例如 new T() 會有編譯器錯誤。理由是Haxe只生成一個單獨的函數,而且構造毫無意義。當類型參數為泛型的時候則不同:因為我們知道編譯器會生成一個不同的函數對于每個類型參數組合,可以使用真實的類型替換 T new T()。 > It is not possible to construct normal type parameters, e.g. new T() is a compiler error. The reason for this is that Haxe generates only a single function and the construct makes no sense in that case. This is different when the type parameter is generic: Since we know that the compiler will generate a distinct function for each type parameter combination,it is possible to replace the T new T() with the real type. ~~~ 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"); } } ~~~ 應該注意,這里使用從下到下的推斷(第3.6.1節)來確定T的實際類型。這種類型的類型參數構建有兩個需求才能工作:構建的類型參數必須是 > It should be noted that top-down inference (3.6.1) is used here to determine the actual type of T. There are two requirements for this kind of type parameter construction to work: The constructed type parameter must be * 是泛型,而且 * 顯式約束(第3.2.1節)為有一個構造參數(第2.3.1節) > * generic and > * be explicitly constrained (3.2.1) to having a constructor (2.3.1). 這里,1,通過使用有 @generic 元數據,2. 通過 T 被約束為可構造的。這個約束適用于String 和haxe.Template 因為它們都有一個構造函數,接受一個單一的Sting參數。果然,相關的JavaScript輸出看起來和預期的一樣: > Here, 1. is given by make having the @:generic metadata, and 2. by T being constrained to Constructible. The constraint holds for both String and haxe.Template as both have a constructor accepting a singular String argument. Sure enough, the relevant JavaScript output looks as expected: ~~~ var Main = function() { } Main.__name__ = true; Main.make_haxe_Template = function() { return new haxe.Template("foo"); } Main.make_String = function() { return new String("foo"); } Main.main = function() { var s = Main.make_String(); 11 var t = Main.make_haxe_Template(); } ~~~
                  <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>

                              哎呀哎呀视频在线观看