question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 9 years ago
  • Comments:10

github_iconTop GitHub Comments

2reactions
CeylonMigrationBotcommented, Nov 14, 2015

[@quintesse] And also that comparing T == T , T == T? or T? == T results in a Boolean while T? == T? results in a Boolean? (given T satisfies Object).

left right result
T T Boolean
T T? Boolean
T? T Boolean
T? T? Boolean?
0reactions
luconocommented, Aug 27, 2017

Have run into this several times and this change would make those cases a lot better.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found