• Download Gist
from recursive method to iterator in scala
1 2 3 4 5 6 7 8 9
def yieldClass2(clazz:Class[_]): Iterator[Class[_]] = {
import scala.collection.{Iterator => I}
clazz match {
case null => I.empty
case _ =>
val interfaces = clazz.getInterfaces map { yieldClass2 } reduceLeft (_ ++ _)
I.single(clazz) ++ yieldClass2(clazz.getSuperclass) ++ interfaces
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.