Kotlin has an excellent feature called string templates. I really love it.
val i = 10 val s = \"i = $i\" // evaluates to \"i = 10\"
But
A couple of examples:
infix fun Double.f(fmt: String) = "%$fmt".format(this) infix fun Double.f(fmt: Float) = "%${if (fmt < 1) fmt + 1 else fmt}f".format(this) val pi = 3.14159265358979323 println("""pi = ${pi f ".2f"}""") println("pi = ${pi f .2f}")