detect inner objects in a scala object -


i want list of inner objects of scala object. sample code:

object outer {   val v = "-"   def d = "-"   object o1   object o2 }  object main {   def main(args: array[string]) {     outer.getclass.getdeclaredmethods.map(_.getname) foreach println  // prints d , v     // outer.getclass.get ... objects???   } } 

i can find v , d, how can find o1 , o2 ?

with new reflection library in scala 2.10 (since milestone 4) possible inner objects:

scala> import scala.reflect.runtime.{universe => u} import scala.reflect.runtime.{universe=>u}  scala> val outer = u.typeof[outer.type] outer: reflect.runtime.universe.type = outer.type  scala> val objects = outer.declarations.filter(_.ismodule).tolist objects: list[reflect.runtime.universe.symbol] = list(object o1, object o2) 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -