<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、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                Haxe 3 允許綁定函數通過部分參數應用。每個函數類型可以被認為是有一個bind字段,可以被調用,傳遞需要數量的參數來創建一個新的函數。下面展示: > Haxe 3 allows binding functions with partially applied arguments. Each function type can be considered to have a bind ?eld, which can be called with the desired number of arguments in order to create a new function. This is demonstrated here: ~~~ class Main { static public function main() { var map = new haxe.ds.IntMap<String>(); var f = map.set.bind(_, "12"); $type(map.set); // Int -> String -> Void $type(f); // Int -> Void f(1); f(2); f(3); trace(map); // {1 => 12, 2 => 12, 3 => 12} } } ~~~ 第4行綁定函數 map.set 到一個變量 f ,然后應用 12 作為第二個參數。下劃線用來表示這個參數沒有綁定,通過對比map.set 和f類型展示:綁定的字符串參數被從類型中有效的切斷,轉換一個 Int->String->Void 類型為 Int->Void 。 > Line 4 binds the function map.set to a variable named f, and applies 12 as second argument. The underscore _ is used to denote that this argument is not bound, which is shown by comparing the types of map.set and f: The bound String argument is effectively cut from the type, turning a Int->String->Void type into Int->Void. 調用 f(1) 然后實際上調用了 map.set(1,"12"),調用 f(2) 和 f(3) 也是類似的。最后一行證明所有三個索引真實的映射到值 “12”。 > A call to f(1) then actually invokes map.set(1, "12"), the calls to f(2) and f(3) are analogous. The last line proves that all three indices indeed are mapped to the value "12". 下劃線 \_ 可以被跳過對于后續的參數,所以第一個參數可以被使用 map.set.bind(1)綁定,生成一個 String->Void 函數,在調用中設置一個新的索引1的值。 > The underscore _ can be skipped for trailing arguments,so the ?rst argument could be bound through map.set.bind(1),yielding a String->Void function that sets a new value for index 1 on invocation. **回調** >[warning] 花絮:回調 Haxe 3以前,曾經使用一個 callback關鍵字,可以被調用為一個函數參數然后后面跟任何數量的綁定參數。這個名字源于一個常見的用法,是一個回調函數被創建和 this 對象被綁定。回調只允許綁定為參數從左到右,因為不支持下劃線。使用下劃線的選擇有一些爭議和一些其他的建議,但是沒有被認為是很優越的。畢竟,下劃線至少看起來像是說“在這里填上值”,很好的描述了它的語義。 >[warning] **Trivia**: Callback Prior to Haxe 3, Haxe used to know a callback-keyword which could be called with a function argument followed by any number of binding arguments. The name originated from a common usage were a callback-function is created with the this-object being bound. Callback would allow binding of arguments only from left to right as there was no support for the underscore _. The choice to use an underscore was controversial and several other suggestions were made, none of which were considered superior. After all, the underscore _ at least looks like it’s saying “?ll value in here”, which nicely describes its semantics.
                  <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>

                              哎呀哎呀视频在线观看