Search code examples
scalascala-2.10

String interpolation: f or s


I wonder, is there any difference between these two:

val a = 123
println(f"hello1 $a") // 1                         
println(s"hello1 $a") // 2

Solution

  • According to the docs, f interpolation is typesafe. Also, it allows to add formatting right after the parameter, which s interpolation doesn't support.