Reflection/List methods: Difference between revisions
Added Kotlin
(added Factor) |
(Added Kotlin) |
||
Line 340:
.filter(function(p) {return typeof p[1] == 'function';})
//[["subOwn", function () {...}]]</lang>
=={{header|Kotlin}}==
Note that kotlin-reflect.jar needs to be included in the classpath for this program.
<lang scala>// 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}")
}</lang>
{{out}}
<pre>
List of methods declared in MyClass and its superclasses:
myInternalMethod, INTERNAL
myPrivateMethod, PRIVATE
myProtectedMethod, PROTECTED
myPublicMethod, PUBLIC
equals, PUBLIC
hashCode, PUBLIC
mySuperClassMethod, PUBLIC
toString, PUBLIC
</pre>
=={{header|Lingo}}==
|