This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Why is RichString.format implemented as it is in 2.7?

No replies
Chris Marshall
Joined: 2009-06-17,
User offline. Last seen 44 weeks 3 days ago.
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

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland