<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之旅 廣告
                變量保存數據,方法被定義程序行為通過托管表達式(第5章)。我們已經在每個代碼例子中看過方法字段,前面的 HelloWorld示例就包含一個 main 方法: > While variables (4.1) hold data, methods are de?ning behavior of a program by hosting expressions (5). We have seen method ?elds in every code example of this document with even the initial Hello World (1.3) example containing a main method: ~~~ class Main { static public function main():Void { trace("Hello World"); } } ~~~ 方法通過 function 關鍵字識別。我們還可以了解到,它們: > Methods are identi?ed by the function keyword. We can also learn that they 1. 有一個名字(這里是main) 2. 有一個參數列表(這里為 empty()) 3. 有一個返回類型(這里是 Void) 4. 可能有訪問修飾符(第4.4節)(這里是 static 和public) 5. 可能有一個表達式(這里是 {trace("Hello World");}) > 1. have a name (here: main), > 2. have an argument list (here: empty ()), > 3. have a return type (here: Void), > 4. may have access modi?ers (4.4) (here: static and public) and > 5. may have an expression (here: {trace("Hello World");}). 還可以看下面的例子,了解更多參數和返回類型的知識: > We can also look at the next example to learn more about arguments and return types: ~~~ class Main { static public function main() { myFunc("foo", 1); } static function myFunc(f:String, i) { return true; } } ~~~ 參數通過字段名后一個開口的 ( 括號開始,一個 逗號 , 作為參數列表中每個參數的分隔符號,然后跟一個閉口的 ) 括號。參數規范的附加信息在 函數類型(第2.6節)中描述。 > Arguments are given by an opening parenthesis ( after the ?eld name, a comma , separated list of argument speci?cations and a closing parenthesis ). Additional information on the argument speci?cation is described in Function Type (Section 2.6). 例子展示了類型推斷如何被使用到兩個參數和返回類型上。方法 myFunc 有兩個參數,但是第一個被顯式賦予類型,f,為String類型。第二個參數 i ,沒有類型示意,留給編譯器從它的調用中推斷它的類型。此外,返回類型通過return ture 表達式來推斷為 Bool 。 > The example demonstrates how type inference(3.6) can be used for both argument and return types. The method myFunc has two arguments but only explicitly gives the type of the ?rst one, f, as String. The second one, i, is not type-hinted and it is left to the compiler to infer its type from calls made to it. Likewise,the return type of the method is inferred from the return true expression as Bool.
                  <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>

                              哎呀哎呀视频在线观看