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

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                一個數組是一個元素的集合。它有一個類型參數(第3.2節),對應這些元素的類型。數組可以被通過以下三種方式創建: * 使用它們的構造函數 : new Array() * 使用數組聲明語法(第5.5節) : [1, 2, 3] * 使用數組推導(第6.6節) : [for (i in 0...10) if ( i % 2 == 0 ) i] 數組附帶一個 API ,覆蓋了多數的用例。另外,它們允許讀/寫 的數組訪問(第5.8節): ~~~ class Main { static public function main() { var a = [1, 2, 3]; trace(a[1]); // 2 a[1] = 1; trace(a[1]); // 1 } } ~~~ 由于 Haxe 中的數組訪問是沒有邊界的,即,數組保證不會拋出異常,這需要進一步討論: * 如果對一個不存在的索引做出一個讀訪問,將根據目標語言返回一個值。 * 如果對一個越界的正索引做出一個寫訪問,null(或者靜態目標語言(第2.2節)中基本類型(第2.1節)的默認值(第2.2節))被插入到最后定義的索引和剛剛寫入的一個索引項。 * 如果使用一個負索引寫訪問,結果是未指定的。 數組在它的元素智商定義了一個迭代器(第6.7節)。這個迭代通常由編譯器優化后使用一個 while 循環(第5.14節)和數組的索引: ~~~ class Main { static public function main() { var scores = [110, 170, 35]; var sum = 0; for (score in scores) { sum += score; } trace(sum); // 315 } } ~~~ Haxe 生成這個優化后的 JavaScript 輸出: ~~~ Main.main = function() { var scores = [110,170,35]; var sum = 0; var _g = 0; while(_g < scores.length) { var score = scores[_g]; ++_g; sum += score; } console.log(sum); }; ~~~ Haxe 不允許混合類型的數組,除非參數類型被限強制為 Dynamic(第2.7節): ~~~ class Main { static public function main() { // Compile Error: Arrays of mixed types are only allowed if the type is // forced to Array<Dynamic> //var myArray = [10, "Bob", false]; // Array<Dynamic> with mixed types var myExplicitArray:Array<Dynamic> = [10, "Sally", true]; } } ~~~ >[warning] **花絮**: 動態數組 > 在Haxe 2中,混合類型的數組聲明是被允許的。在Haxe 3中,數組只有顯式聲明為 Array<Dynamic> 才可以為混合類型。 查看數組API了解它的方法的詳細內容。
                  <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>

                              哎呀哎呀视频在线观看