How to get the actual type of a generic type?

There is a class with generic type:

class Action[T]

Create some instances of it, put in a list:

val list = List(new Action[String], new Action[Int])

Iterate it, and how to get the actual type of the instances?

list foreach { action =>
     // how do I know the action is for a String or an Int?
}
9
задан Freewind 22 March 2011 в 17:01
поделиться