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.

No equality operators for IUser (and possibly others)

See original GitHub issue

This makes it impossible to use LINQ and other built-in methods for ensuring that objects are equal to each other. Will submit a pull request with this.

IReadOnlyCollection<IUser> usersReacted = await msg.GetReactionUsersAsync(emote.Name); // Returns list of 25 users (subset of everyone in guild)
IReadOnlyCollection<IUser> usersInGuild = sguser.Guild.Users; // Returns list of 50 users
IEnumerable<IUser> usersToRemove = usersInGuild.Except(usersReacted); // Should return everyone in the guild except those who reacted

usersToRemove ends up being the same as usersInGuild. I’ll try and find a less-painful solution than doing things manually.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Joe4evrcommented, Dec 23, 2017

Thus, the only kind of thing I can think of doing is writing my own method that steps through both collections and only takes the unique values based on ID

.Except() (and just about every other LINQ method) has an overload that takes in an IEqualityComparer<T> at which point you can just do something like this. No need to write your own methods.

0reactions
Still34commented, Apr 8, 2018

Should probably be closed now that comparers have been added.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Not Equal – Does Not Equal Operator Tutorial
The not equal operator is a relational or comparison operator that compares two or more values (operands). It returns either true or false ......
Read more >
No == operator found while comparing structs in C++
In C++, struct s do not have a comparison operator generated by default. You need to write your own: bool operator==(const MyStruct1& lhs, ......
Read more >
Equality operators - test if two objects are equal or not
In this article​​ The == (equality) and != (inequality) operators check if their operands are equal or not. Value types are equal when...
Read more >
Equality, Relational, and Conditional Operators
The equality and relational operators determine if one operand is greater than, less than, equal to, or not equal to another operand. The...
Read more >
Comparison operators
6) Returns true if lhs is not equal to rhs, false otherwise. In all cases, for the built-in operators, lhs and rhs must...
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