-
-
Save markhuyong/8132209 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
import scala.xml._ | |
val xml: Elem = XML.load("./input.xml") | |
val formatted: String = new PrettyPrinter(80, 2).format(xml) | |
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
//Scala 2.10 ReflectionSugars | |
trait ReflectionSugars{ | |
import scala.reflect.runtime.{universe => ru} | |
private lazy val universeMirror = ru.runtimeMirror(getClass.getClassLoader) | |
def companionOf[T](implicit tt: ru.TypeTag[T]) = { | |
val companionMirror = universeMirror.reflectModule(ru.typeOf[T].typeSymbol.companionSymbol.asModule) | |
companionMirror.instance | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment