RosettaCodeData/Task/Reflection-List-methods/Scala/reflection-list-methods.scala

17 lines
451 B
Scala

object ListMethods extends App {
private val obj = new {
def examplePublicInstanceMethod(c: Char, d: Double) = 42
private def examplePrivateInstanceMethod(s: String) = true
}
private val clazz = obj.getClass
println("All public methods (including inherited):")
clazz.getMethods.foreach(m => println(s"${m}"))
println("\nAll declared fields (excluding inherited):")
clazz.getDeclaredMethods.foreach(m => println(s"${m}}"))
}