- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Why is RichString.format implemented as it is in 2.7?
Thu, 2010-02-25, 16:04
I'm not really understanding why something so critical as formatting a String has been implemented via reflection
def format(args : Any*) : String = {
val m = classOf[String].getDeclaredMethod("format", classOf[String], classOf[Array[Object]])
m.invoke(null, self,
args.asInstanceOf[scala.runtime.BoxedObjectArray].
unbox(args.getClass).asInstanceOf[Array[Object]]).asInstanceOf[String]
}
This seems to have changed with 2.8 but I'd be interested to understand the original reasons for it.
Chris
Do you want a Hotmail account? Sign-up now - Free
def format(args : Any*) : String = {
val m = classOf[String].getDeclaredMethod("format", classOf[String], classOf[Array[Object]])
m.invoke(null, self,
args.asInstanceOf[scala.runtime.BoxedObjectArray].
unbox(args.getClass).asInstanceOf[Array[Object]]).asInstanceOf[String]
}
This seems to have changed with 2.8 but I'd be interested to understand the original reasons for it.
Chris
Do you want a Hotmail account? Sign-up now - Free