Open jubax opened 4 months ago
The "problem" is not specific to .formatted()
but applies to all methods with argument. Example:
public class C {
public static void main(String[] args) {
new String("""
hello
""".formatted(
"HalloVeryLongStringHalloVeryLongStringHalloVeryLongStringHalloVeryLongStringHalloVeryLongStringHalloVeryLongString"));
new String("hello".formatted(
"HalloVeryLongStringHalloVeryLongStringHalloVeryLongStringHalloVeryLongStringHalloVeryLongStringHalloVeryLongString"));
new Integer("""
hello
""".indexOf(
"HalloVeryLongStringHalloVeryLongStringHalloVeryLongStringHalloVeryLongStringHalloVeryLongStringHalloVeryLongString"));
new Integer("hello".indexOf(
"HalloVeryLongStringHalloVeryLongStringHalloVeryLongStringHalloVeryLongStringHalloVeryLongStringHalloVeryLongString"));
}
}
however i don't see that regular Strings are any other in my simplified example.
The String.formatted() method is not correctly intended for text blocks: I want:
but I get
For regular strings the formatting is better. But I think it is wrong that the formatting does not add another indentation level.