-
Notifications
You must be signed in to change notification settings - Fork 4.2k
update: clarify null-handling behavior of==operator #4808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
f3e5341
to
8beefa7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some suggestions for the text :)
docs/topics/operator-overloading.md
Outdated
Kotlin calls `.equals()` when neither operand is the `null` literal and the comparison isn’t between two floating-point types. | ||
Otherwise, `===` is used for `null` literal checks, and non-null floating-point values are compared by numeric value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of "the null
literal" can we say "a null
value"?
And "===
is used to check for null
values" rather than "===
is used for null
literal checks"?
And can you make the second sentence active? "Kotlin uses ===
" or something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of "the null literal" can we say "a null value"?
🤔 It's an important difference here. With two expressions A and B, A == B expands to A?.equals(B) ?: (B === null) even with a null value. If either operand is literal null
, A == B instead expands to A === B.
And can you make the second sentence active? "Kotlin uses ===" or something like that?
Sure thing 👍
This update is intended to clarify the null-handling behavior of the
==
operator for KT-74113Restructured text approved by Nikita Bobko