Last active
January 13, 2016 00:17
-
-
Save andyscott/09471d62665647781186 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val cl = // a valid ClassLoader | |
val classNames: List[String] = | |
classOf[String].getName :: "$$$$" :: List.getClass.getName :: Nil | |
type Acc = (List[Throwable], List[Class[_]]) | |
val res = classNames.foldLeft((Nil, Nil): Acc) { (acc, className) ⇒ | |
Try(Class.forName(className, true, cl)) match { | |
case Success(c) ⇒ (acc._1, c :: acc._2) | |
case Failure(f) ⇒ (f :: acc._1, acc._2) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment