<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智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                類型參數可以被約束為多種類型: > Type parameters can be constrained to multiple types: ~~~ typedef Measurable = { public var length(default, null):Int; } class Main { static public function main() { trace(test([])); trace(test(["bar", "foo"])); // String should be Iterable<String> //test("foo"); } static function test<T:(Iterable<String>, Measurable)>(a:T) { if (a.length == 0) return "empty"; return a.iterator().next(); } } ~~~ 方法test的類型參數T被約束為Iterable<String>和Measurable。后者方便起見被使用一個 typedef(第3.1節)定義,需要兼容有一個只讀(第4.2節)的Int類型length屬性的類型。約束然后說一個類型是兼容的,如果: > Type parameterT of method test is constrained to the types Iterable<String> and Measurable. The latter is de?ned using a typedef (3.1) for convenience and requires compatible types to have a read-only property (4.2) named length of type Int. The constraints then say that a type is compatible if * 和 Iterable<String>兼容 * 并且有一個Int類型的length屬性 > * it is compatible with Iterable<String> and > * has a length-property of type Int. 我們可以看到,在第7行調用test并傳遞一個空的數組,和第8行一個Array<String>是沒有問題的。因為數組都有length屬性和一個 iterable 方法。然而,傳遞一個字符串作為參數,如第9行則會導致約束失敗,因為字符串不兼容 Iterable<T>。 > We can see that invoking test with an empty array in line 7 and an Array<String> in line 8 works ?ne. This is because Array has both a length-property and an iterator-method. However, passing a String as argument in line 9 fails the constraint check because String is not compatible with Iterable<T>.
                  <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>

                              哎呀哎呀视频在线观看