In short.
The method is in the scope of the class or object.
There is no function.
Longer versions.
Think of objects as pieces of a larger system. So your application has a global scope, inside of which there are objects that describe ... well ... objects. A good example of the real world that I like to use: if you have a program that talks about your home and in your home, you have a lot of objects, a table, a sink and a person. Now a person can turn on the sink. Thus, the person has a way of inclusion, and the shell will have the On property. It might look something like this.
person.turn_on(sink)
Now the sink can’t turn on a person ... (well, maybe this is another story) Anyway, it won’t work out
sink.turn_on (person)
If they were not methods and were “functions”, you could have something like this
function turn_on (who what) # some app code to enable its end
Then you can call it as follows
turn_on(person, sink)
This does not make sense for the program, why one could invoke a table to include something. Why wasn't it a mistake before?
What is more descriptive?
Now think about it in terms of tables, the table cannot be included or change anything, so it will not have these two attributes (method and local variable)
I hope this helps
source share