Box/unbox a primitive in Scala

If you have a primitive type in Scala, you may need to “box” it, by turning it into a real JVM object, like so:

String.format("%-30s: %.2f ± %0.2f", kv._1,,

This creates “java.lang.Double” from “scala.Double”.

Interested in Scala? I send out weekly, personalized emails with articles and conference talks. Click here to see an example and subscribe.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *