Kotlin Reference section on Functions states that 'A member function is a function that is defined inside a class or object':
I have also seen references to methods in Kotlin. Are methods and member functions the same, different or misuse of terms?
AFAIK yes, same.
Kotlin is a bit different from Java because there are for example top level functions, and functions in companion objects, functions within functions, extension functions, etc. Everything in Kotlin starts with fun
is called a (some kind of) function.
In Java, there are less types of functions. There are static (class-level) functions and object-level methods. The latter expression comes from OOP world, and Java is an OOP language, while Kotlin is not just that.
Methods and member functions are synonyms. Much like object attributes are called member fields. Synonyms, however, have often little differences or shades of meanings. For instance, the word old can be expressed with synonyms ancient, venerable, elderly or matured. Each of the words describes the same thing with some different shades of meanings.
Kotlin is a powerful functional programming language. In functional languages, the term function is very important. Kotlin functions are much powerful than Java or C# methods. If we called them methods, this would imply similar to C# and Java. The term member function reflects the power and flexibility of the Kotlin function better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With