What is a difference between a method and a function?

后端 未结 7 1479
礼貌的吻别
礼貌的吻别 2020-12-08 00:15

What is the difference between a method and a function? Is it that a method returns a value and a function doesn\'t?

7条回答
  •  一个人的身影
    2020-12-08 00:32

    In one line, a method is a function but a function is not necessarily a method. The difference is that a method is used to describe functions defined in classes that are used with instances of those classes.

    package {class Example {
      public function iAmAMethod():void {
         addEventListener("listenerFunctionIsNotAMethod", function(event:Event):void {
            trace("inline function, yay!");
         });
      }
    

    }

提交回复
热议问题