Scala runtime string interpolation/formatting

前端 未结 3 2004
青春惊慌失措
青春惊慌失措 2021-01-20 11:10

Are there any standard library facilities to do string interpolation/formatting at runtime? I\'d like the formatting to behave exactly the same as the macro based s\"s

3条回答
  •  北恋
    北恋 (楼主)
    2021-01-20 12:05

    A. As of Scala 2.10.3, you can't use StringContext.f unless you know the number of arguments at compile time since the .f method is a macro.

    B. Use String.format, just like you would in the good ol' days of Java.

提交回复
热议问题