How do the PHP equality (== double equals) and identity (=== triple equals) comparison operators differ?

What is the difference between == and ===? How exactly does the loosely == comparison work? How exactly does the strict === comparison work? What would be some useful examples?

How to determine equality for two JavaScript objects?

A strict equality operator will tell you if two object types are equal. However, is there a way to tell if two objects are equal, much like the hash code value in Java? Stack Overflow question Is...

Which equals operator (== vs ===) should be used in JavaScript comparisons?

I'm using JSLint to go through JavaScript, and it's returning many suggestions to replace == (two equals signs) with === (three equals signs) when doing things like comparing...

Can't operator == be applied to generic types in C#?

According to the documentation of the == operator in MSDN, For predefined value types, the equality operator (==) returns true if the values of its operands are equal, false otherwise. For...

Good way to hash a float vector?

I am well aware of all the problems involved in comparing floats. This is exactly the reason for this question. I'm looking to create a fast hash table for values that are 3D vectors (3 floats -...

Operator Overloading with Interface-Based Programming in C#

Background I am using interface-based programming on a current project and have run into a problem when overloading operators (specifically the Equality and Inequality...

Reference — What does this symbol mean in PHP?

What is this? This is a collection of questions that come up every now and then about syntax in PHP. This is also a Community Wiki, so everyone is invited to participate in maintaining this...

Javascript string comparison fails when comparing unicode characters

I want to compare two strings in JavaScript that are the same, and yet the equality operator == returns false. One string contains a special character (eg. the danish å). JavaScript code: var...

Customise actual/expected "Value of" string in Google Test failure output messages

I have the following output from a Google Test unit test: UnitTests.cc:56: Failure Value of: LineSegment2i(Vector2i(-10,0), Vector2i(-10,10)).toLine() Actual: 24-byte object <00-00 00-00 00-00...

Comparing two structs using ==

I am trying to compare two structs using equals (==) in C#. My struct is below: public struct CisSettings : IEquatable<CisSettings> { public int Gain { get; private set; } public int...

std::find Object by Member

Scenario I’ve run into a speedbump while using the STL with what seems like a normal scenario, simplified here: class Person { string Name; int Age; }; vector<Person>...

What does the == operator actually do on a Python dictionary?

Consider: >>> a = {'foo': {'bar': 3}} >>> b = {'foo': {'bar': 3}} >>> a == b True According to the python doc, you can indeed use the == operator on dictionaries. What is actually happening...

Shell equality operators (=, ==, -eq)

Can someone please explain the difference between =, == and -eq in shell scripting? Is there any difference between the following? [ $a = $b ] [ $a == $b ] [ $a -eq $b ] Is it simply that = and...

How can I make a Python object always return true for an equality test?

EDIT: The following code had a simple mistake which didn't actually illustrate the problem. I've left it here(uncorrected), but I'm still curious about answers to the questions at the bottom. I...

Why does non-equality check of one variable against many values always return true?

I have a variable v in my program, and it may take any value from the set of values "a", "b", "c", ..., "z" And my goal is to execute some statement only when v is not "x", "y", or "z". I have...

Private inheritance from vector, exposing equality operator

I need a vector which stores elements in sorted order (I need constant-time random access too, so not std::set). I am trying to implement that by privately inheriting std::vector. template...

How to design generic filtering operators in the query string of an API?

I'm building a generic API with content and a schema that can be user-defined. I want to add filtering logic to API responses, so that users can query for specific objects they've stored in the...

Ruby's case equality operator (`===`) is backwards for RSpec's `expect`

I'm running a bunch of data-driven specs, and the expected data is in different classes (because I have to use Regexps sometimes, because the output string changes each time but always follows a...

DateTime subtraction not working in PowerShell - assignment vs. equality operator

Today (2017-05-29) I am using PowerShell 5.0.10586.117 on Windows 7 Enterprise and run the following (shortened): $dateOfLicense = "2017-04-20" $dateOfToday = '{0:yyyy-MM-dd}' -f...

Why can't Swift's greater-than or less-than operators compare optionals when the equality operators can?

In Swift 3, this is a compile error, if I use > or < let a: Int? guard a > 0 else {return} guard a < 0 else {return} Compile error: Value of optional type 'Int?' not unwrapped; did you mean to...

What is the best practice to implement equality for readonly structs?

I've just started to program in C# last year and I'm still learning the language. I have a question regarding readonly struct type and equality comparison methods. When creating a struct in C#, I...

Why operator inside parenthesis changes `this` in function call

Talk is cheap; show me the code. // equals to this.test = "inside window" var test = "inside window"; function f () { console.log(this.test) }; var obj = { test: "inside object", fn:...

When and why to use a "ValueObject" base class (from the Microsoft Docs) in C#?

I am trying to understand the use case for ValueObject in C#, when to use and what's the need for ValueObject. I see in the documentation that it can be used when we want to initialize object and...

Does STARTSWITH on Cosmos partition keys optimize "fan-out" of cross-partition queries?

Microsoft makes it clear that cross-partition queries "fan-out" the query to each partition (link): The following query doesn't have a filter on the partition key (DeviceId). Therefore, it must...

Equality operator `==` invocation with references of unrelated types while using data_connection_checker package

To check for internet connection i am using data_connection_checker package but it seems that I am not getting how to use it. I am using following code to check internet connection by calling in...

Implementing an Outer Join using "greater than" operator

I'm writing a Kusto query to return logging events from AppInsights. I have a custom event representing a "Password Reset Request" and this should be followed by a "Password Reset Confirmed"...

How to use typeof operator to check if function is a string

Task Instructions Your task in this activity is to create a function called isString that takes three arguments (a, b, c). This function does the following: It uses the typeof operator and strict...

Can comparison operator be defaulted outside of class definition in C++20?

Starting from C++20, the compiler can automatically generate comparison operators for user classes by means of operator ==() = default syntax. But must this operator be defaulted only inside the...

Order of evaluation of assignment expressions (walrus operator)

I have the following expression: >>> a = 3 >>> b = 2 >>> a == (a := b) False Now, a == 2 after the operation, as expected. And the result is what I would want, i.e., comparison of a to RHS of...

Implicit operator != resolving ambiguity in operators ==

If some struct A has explicitly declared operator == method, but at the same time there is a global operator == accepting arguments of type A, then equality comparison shall result in ambiguity...