Format and convert

The truth is that programmers often need to embed dynamic variables into static string patterns. To accomplish this feat we used to write something like:

or even

A good news is that Scala 2.10 brings a shiny new string interpolation:

The new syntax is more concise, offers more static checking and provides a better runtime performance.

To facilitate the transition, Scala plugin introduced a new group of intentions to easily convert between all the variants of string formatting:

In addition, we now have a complete format string and argument verification in the following places:

  • "…".format(…)
  • ….formatted("…")
  • String.format("…", …)
  • printf("…", …)
  • System.out.printf("…", …)
  • Interpolated strings

The verification is even more fine-grained than the similar one in Java:

All the functionality is already available in the Scala plugin nightly builds (Nika | Leda).