Can someone provide a simple explanation of methods vs. functions in OOP context?
They're often interchangeable, but a method usually refers to a subroutine inside a class, and a function usually refers to a subroutine outside the class. for instance, in Ruby:
# function
def putSqr(a)
puts a ** 2
end
class Math2
# method
def putSqr(a)
puts a ** 2
end
end
In Java, where everything (except package and import statements) must be inside the class, people almost always refer to them as "methods".