RFR - JDK-8203444 String::formatted (Preview)
james.laskey at oracle.com
Tue May 21 14:52:03 UTC 2019
All discussion is valid. I agree the ambiguity is tricky, but can be resolved by using explicit locale.
This guarantees the "public String formatted(Locale l, Object... args)" form is chosen with the second Locale as an argument.
> On May 21, 2019, at 11:42 AM, Florian Weimer <fweimer at redhat.com> wrote:
> * Jim Laskey:
>> Please do a code review of the new String::formatted instance method. This method was originally introduced under the name "format"
>> in conjunction with Raw String Literals. The method is being reintroduced in conjunction with Text Blocks and renamed to avoid method
>> resolution conflicts against the static method String::format.
>> Example of use:
>> String name = "Smith, Pat";
>> String address = "123 Maple St., Anytown, Anywhere";
>> String phone = "999-555-1234";
>> String client = """
>> Name: %s
>> Address: %s
>> Phone: %s
>> """.formatted(name, address, phone);
> I'm a bit concerned by the ambiguity between the version with and
> without the Locale argument. Not sure if this is the kind of feedback
> you are looking for.
> (String::format does not have this ambiguity and had been able to avoid
> it easily, so it's not a good guide here.)
More information about the core-libs-dev