<i18n dev> RFR: 8342863: Use pattern matching for instanceof in equals methods of wrapper classes
Chen Liang
liach at openjdk.org
Wed Oct 23 16:13:09 UTC 2024
On Wed, 23 Oct 2024 15:37:00 GMT, Joe Darcy <darcy at openjdk.org> wrote:
>> src/java.base/share/classes/java/lang/Long.java line 1249:
>>
>>> 1247: public boolean equals(Object obj) {
>>> 1248: if (obj instanceof Long ell) {
>>> 1249: return value == ell.longValue();
>>
>> Suggestion:
>>
>> if (obj instanceof Long l) {
>> return value == l.longValue();
>
> In other place in the code, I've written out "ell" to avoid any confusion between lowercase "l" and a number "1", etc.
What does "ell" stand for? Looks like "eel" to me.
That aside, if there's no good name, we usually use `that` or `o` for the casted variable, like
return obj instanceof Long that && this.value == that.value;
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21652#discussion_r1813114216
More information about the i18n-dev
mailing list