Questions tagged [equality]

Equality is a relationship between two or more items or variables or objects that exists if (1) the items are the same item, variable, or object or (2) the items are different items, variables or objects but they have the same value. This tag should generally be used with programming language specific tags as well as other contextual tags such as database system. The post should include as much context about the equality test as is possible.

This tag is typically used for questions concerning how to determine if two objects or variables are either the same object or different objects with the same value. Questions almost always require a programming language tag and other tags for context.

Programming languages represent variables, objects, or other storage containers using different underlying mechanisms for the storage of the values of variables and objects. A test for equality is to compare some characteristic of two variables or objects to determine if the characteristic is the same.

This characteristic is typically either (1) the storage identifier such as a reference handle, memory address, etc. when checking if the two are the same object or (2) the characteristic is the value of the objects retrieved using a storage identifier when checking if the value of the two are the same value.

Different programming languages and different operating environments have differences in how equality is tested and what operators are used to express a test for equality. In some cases various conversions from underlying storage representations may be involved in testing for equality.

See What is the difference between equality and equivalence? as well as Equivalence relation and natural ordering on a class in Java

2095 questions
0
votes
3 answers

Kotlin modifying dataclass object key from map changes the reference after modifying variable

I have a MutableMap that its keys are objects from a DataClass (User dataclass), and the values are arrays from other Dataclass (Dog dataclass). If i have a variable with a User object, and i put it in the MutableMap and i test if the map contains…
0
votes
1 answer

mysql condition 'equal' shows condition 'like' attributes

select * from order_info where order_id = 48; The mysql command show above is a very simple sentence, but the result below seems not to meet my expectation, it is more similar to like condition. retrieval result I don't know if the type of field…
0
votes
0 answers

How to compare equality of values in a single object to the values in an array of objects?

I'm new to Javascript and I'm working on a project but am stuck. I have a singular object that has been user generated based on a questionnaire and I now want to compare the value data to the data in the matching keys in multiple objects that's in…
Dan
  • 1
0
votes
1 answer

Why is my list equal check not working when they look the same in Flutter?

Part of my Flutter program creates a list and later checks to see if the list is equal to another. However, when I test this, it returns false. I've done a series of printout statements to check why they aren't equal and they look the same, but it…
0
votes
0 answers

Identical strings don't seem to be treated as identical for the if statement

I am writing a small program to read a list of passwords and search for a password that has been inputted by the user. For some reason, even if I deliberately enter a password that is in the file, it doesn't print that the password is found. Below…
0
votes
2 answers

Does the `===` operator in Javascript have separate definitions for primitives vs non-primitives?

With the === operator in Javascript, if it operators on primitives, it returns false if either the values are different or the types are different. If it's operating on non-primitives, it returns false if the two operands don't point to the same…
0
votes
1 answer

Applying Reflexivity of String Equivalence in Agda Proofs

In my Agda program, I have a small function that checks for string equality (simplified for example): open import Data.String.Base using (String) open import Date.String.Properties using (_≈?_) open import Relation.Nullary.Decidable using…
0
votes
1 answer

Could not load file or assembly 'Microsoft.QualityTools.Testing.Fakes' or one of its dependencies

This happened in Visual Studio 2022 Community version. System.IO.FileLoadException: Could not load file or assembly 'Microsoft.QualityTools.Testing.Fakes' or one of its dependencies. Access is denied. File name:…
0
votes
1 answer

I’m making sure the user enters a number a valid number. If persons doesn’t enter a number, the if statement somehow works? How is this working?

This is a very small part of our college groupwork. We’d have to present our code and explain how each part of the code works. We wanted to ensure that the user enters an integer and prompt the user to reenter if they didn’t enter a valid number. We…
user20596957
0
votes
1 answer

How to pass a custom equality_check function into perfplot

I'm working with the perfplot library to compare the performance of three functions f1, f2 and f3. The functions are supposed to return the same values, so I want to do equality checks. However, all other examples of perfplot I can find on the…
cottontail
  • 10,268
  • 18
  • 50
  • 51
0
votes
0 answers

MATLAB says my matrices on both side of equal sign are not equal in size

This is my code syms xi eta N1 = ((1+xi)*(1+eta))/4; N2 = ((1-xi)*(1+eta))/4; N3 = ((1-xi)*(1-eta))/4; N4 = ((1+xi)*(1-eta))/4; Nxieta = [N1 N2 N3 N4]; difNxieta = sym(zeros(2,4)) for i = 1:4 difNxieta(1,i) =…
Faito Dayo
  • 115
  • 4
0
votes
0 answers

js fuction to compare 2 items for equality

Trying to create a function that would compare 2 items based on equality. Unfortunately, it doesn't work properly please help. //This is what I have so far: function checkEquality(a,b){ if (a===b) { return "The type and values are…
Kat Shepil
  • 25
  • 3
0
votes
1 answer

Python "if" statement does not equal

I am trying to create a function that accepts 5, 10, and 25 as input, re-prompting the user if one of those numbers is not inputted. def get_paid(y): while True: n = int(input("Insert Coin: ")) if n != 5 or 10 or 25: …
bwags
  • 1
  • 1
0
votes
1 answer

How do I test if two lists are equal?

var a=[1,2,3] var b=[1,2,3] var c=[1,2,4] System.print(a==b) System.print(a==c) How do I check if two lists are equal? I tried the equality operator == but this doesn't work; it prints false and false
congusbongus
  • 13,359
  • 7
  • 71
  • 99
0
votes
6 answers

Java not saying that two Strings equal when they do?

Possible Duplicate: String comparison in Java heres my script: public class euler4 { /** * a palindromatic number reads the same both ways. the largest palindrome * made from the product of 2-digit numbers is 9009 = 91 * 99. …
bzupnick
  • 2,646
  • 4
  • 25
  • 34