Is a method the same as a function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Is a method the same as a function?

1st May 2018, 3:36 PM
James John Chirwa
James John Chirwa - avatar
5 Answers
+ 10
Well a method is a function that is defined inside a class and associated with that class. So there is a slight difference. In Object Oriented Programming, if I define a class, all "functions" in that class will be called methods. For more answers (though it is about Java it pretty much applies to other languages too): https://www.quora.com/What-is-the-difference-between-function-and-method-in-java
1st May 2018, 3:46 PM
cyk
cyk - avatar
+ 1
Yep.
1st May 2018, 3:49 PM
Aaron Stone
Aaron Stone - avatar
0
yes
1st May 2018, 4:15 PM
Abdul Qayyum
Abdul Qayyum - avatar
0
I think the only different between function and method is that it can be called anywhere in the program outside the def part of that particular function but the latter could only be invoked only with the help of objects. Like x.f() where f() is a method and x is an object(variable of some datatype int,str,list etc).
3rd May 2018, 7:38 AM
Anand Krishnan
Anand Krishnan - avatar
0
method is not same as function it differs in every language
10th May 2018, 8:00 AM
Dhanuswetha.K.S
Dhanuswetha.K.S - avatar