I want to know the name of a given object in a class
class B {
abstract class F{
def name = getClass.getSimpleName
}
object FI extends F
}
val b = new B
println(b.FI)
With Scala 2.9.1 it prints B$FI$
With Scala 2.9.2 it prints FI$
What I really want is “FI”. What is the best way to get FI and be sure that it won’t change in future versions of scala? Is there some reflection support to help me?
This is possible with the new reflection API introduced in Scala 2.10 as follows: