equality and null
See original GitHub issue[@gavinking] We finally thought of an acceptable approach to equality and null
. We propose to make ==
accept non-definite typed operands, but in the case that both operands are non-definite types, we will assign it the type Boolean?
, and have it evaluate to null
in the case that both operands evaluate to null
.
So, you can write:
if (maybeCat==maybeTruck else false) {
...
}
The remaining question is whether we should make this the behavior of a new operator =?=
.
[Migrated from ceylon/ceylon-spec#1089]
Issue Analytics
- State:
- Created 9 years ago
- Comments:10
Top Results From Across the Web
Java null check why use == instead of .equals()
equals() checks to see if two objects are equal according to their contract for what equality means. It's entirely possible for two distinct...
Read more >How to Use Comparison Operators with NULLs in SQL
This article is going to help you master best practices for crafting SQL queries that work with NULL values and use comparison operators...
Read more >Does Null Equal Null in Java? - JoeHx Blog
the answer is a simple yes. Which makes sense, otherwise there'd have to be another way to check if an object is not...
Read more >EQUAL_NULL
Compares whether two expressions are equal. The function is NULL-safe, meaning it treats NULLs as known values for comparing equality.
Read more >Equals Equals Null in JavaScript
Despite the fact that null is a falsy value (i.e. it evaluates to false if coerced to a boolean), it isn't considered loosely...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
[@quintesse] And also that comparing
T == T
,T == T?
orT? == T
results in aBoolean
whileT? == T?
results in aBoolean?
(given T satisfies Object).Have run into this several times and this change would make those cases a lot better.