Task

The goal is to get the methods of an object, as names, values or both.

Some languages offer dynamic methods, which in general can only be inspected if a class' public API includes a way of listing them.

// Version 1.2.31
 
import kotlin.reflect.full.functions
 
open class MySuperClass {
    fun mySuperClassMethod(){}
}
 
open class MyClass : MySuperClass() {
    fun myPublicMethod(){}
 
    internal fun myInternalMethod(){}
 
    protected fun myProtectedMethod(){}
 
    private fun myPrivateMethod(){}
}
 
fun main(args: Array<String>) {
    val c = MyClass::class
    println("List of methods declared in ${c.simpleName} and its superclasses:\n")
    val fs = c.functions
    for (f in fs) println("${f.name}, ${f.visibility}")
}