Scala code I have
System.out.println(String.format("%s %6d", "someName", someLong))
and the error:
overloaded method value format with alternatives:
[error] (java.util.Locale,java.lang.String,<repeated...>[java.lang.Object])java.lang.String <and>
[error] (java.lang.String,<repeated...>[java.lang.Object])java.lang.String
[error] cannot be applied to (java.lang.String, Long, String)
[error] System.out.println(String.format("%s %6d", "someName", someLong))
How do I solve this?
To illustrate Randall's answer.
If you're over fifty, use Randall's answer, but if you're under forty or can still wear fitted shirts, use the f-interpolator! Life is short.
scala> String.format("%s %6d", "someName", someLong: java.lang.Long)
res8: String = someName 5
scala> val someName = "Bob"
someName: String = Bob
scala> f"${someName} ${someLong}%6d"
res10: String = Bob 5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With