What's the difference between a method and a function?

前端 未结 30 4386
粉色の甜心
粉色の甜心 2020-11-21 05:08

Can someone provide a simple explanation of methods vs. functions in OOP context?

30条回答
  •  庸人自扰
    2020-11-21 05:47

    I know many others have already answered, but I found following is a simple, yet effective single line answer. Though it doesn't look a lot better than others answers here, but if you read it carefully, it has everything you need to know about the method vs function.

    A method is a function that has a defined receiver, in OOP terms, a method is a function on an instance of an object.

提交回复
热议问题