|
Wordle 986 3/6*
β¬π¨π¨β¬β¬
β¬β¬β¬π¨π¨
π©π©π©π©π©
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
986 3/6
π©β¬β¬β¬β¬
π©β¬π¨π¨β¬
π©π©π©π©π©
wordle.at
Rules for the FOSW ![ ^]
MessageBox.Show(!string.IsNullOrWhiteSpace(_signature)
? $"This is my signature:{Environment.NewLine}{_signature}": "404-Signature not found");
|
|
|
|
|
β¬π¨β¬β¬β¬
β¬β¬π¨β¬β¬
π¨π©π¨β¬β¬
π©π©π©π©β¬
π©π©π©π©π©
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Wordle 986 5/6
π¨β¬β¬β¬β¬
β¬β¬β¬β¬π¨
β¬β¬π©β¬π©
β¬π©π©β¬π©
π©π©π©π©π©
|
|
|
|
|
Wordle 986 4/6*
π¨π¨β¬β¬β¬
β¬π©π©π©β¬
β¬π©π©π©β¬
π©π©π©π©π©
Happiness will never come to those who fail to appreciate what they already have. -Anon
And those who were seen dancing were thought to be insane by those who could not hear the music. -Frederick Nietzsche
|
|
|
|
|
Wordle 986 4/6
β¬β¬π¨β¬β¬
π¨π¨β¬β¬π¨
π¨π¨π¨β¬β¬
π©π©π©π©π©
Ok, I have had my coffee, so you can all come out now!
|
|
|
|
|
Wordle 986 5/6*
β¬π¨π¨β¬β¬
β¬β¬π¨π¨π¨
π¨π©π¨β¬β¬
π©π©π©π©β¬
π©π©π©π©π©
|
|
|
|
|
|
Danny Elfman would be very disappointed in you using his band name.
Iβve given up trying to be calm. However, I am open to feeling slightly less agitated.
Iβm begging you for the benefit of everyone, donβt be STUPID.
|
|
|
|
|
This looks like an orphaned post
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Well, that happened to OG as well lately, did someone play with the matrix again?
Rules for the FOSW ![ ^]
MessageBox.Show(!string.IsNullOrWhiteSpace(_signature)
? $"This is my signature:{Environment.NewLine}{_signature}": "404-Signature not found");
|
|
|
|
|
Someone really should start a weekly blog of inane .NET logic when it comes to what it does or does not throw an exception for vs. just behaving according to some default arbitrary choice.
Entry #1:
On an empty collection, .Any() , with our without a condition, always returns false , as any sane person would expect.
However, .All(condition) , on an empty collection, returns true .
HUH?
If I look at an empty room and ask "Are all the people in there aliens?" the answer I expect is apparently YES?
If ever there were a situation where a method call is so nonsensical that there is no possible objectively right way to handle that which everyone would agree on (thus justifying an Exception), it's asking about All the items in an empty collection. It's tantamount to division by zero.
And yet on a null collection, even though these are all extension methods and perfectly capable of treating null as empty, it throws .NET's all time favorite and #1 most useless exception, NulLReferenceException .
Clearly the .NET developers' goal is to ruin as many of my days as possible.
|
|
|
|
|
I can see what you mean, but I can see the logic as well -- so I agree with MS on this.
With Any, you begin by setting the result to false, then iterate the tests, if any of the tests is true, you return true -- so no tests yields false.
With All, you begin by setting the result to true, then iterate the tests, if any of the tests is false, you return false -- so no tests yields true.
Both have a short-circuit feature, which is a good thing.
I definitely agree that MS needed to have a more cohesive development team who communicated and decided on things like this.
|
|
|
|
|
Well look I'm not saying there's no good argument in favor of [Empty].All() returning true , and I totally get the programming logic of starting with true and breaking if and only if you find a false . It's not like the decision is unjustifiable. But I think the "Right Thing" to do here is more than sufficiently debatable that if ever there was a time to throw an exception (which they love to do in countless other contexts) it would be here.
|
|
|
|
|
I disagree with throwing an exception for that an empty collection.
modified 29-Feb-24 16:16pm.
|
|
|
|
|
Only because you agree with their logic. Not everyone does. The ambiguity is the issue, not whether you or I agree with the decision.
|
|
|
|
|
The trouble is that you're explaining the logic of the implementation, whereas the question concerns the logic of the outcome. The outcomes of .Any() and .All() on empty collections are logically inconsistent. Logically the answer to whether anything in an empty collection or everything in the same collection meet some criterion is "No" in both cases. Similarly a null exception is absurd.
My guess is that whoever coded and reviewed one of the two methods didn't first grasp the behaviour of the other. It happens a lot, in my experience.
|
|
|
|
|
Exactly. A lack of communication.
The specs for the methods should have specified what the result should be for an empty set -- probably false.
|
|
|
|
|
Peter Moore - Chicago wrote: If I look at an empty room and ask "Are all the people in there aliens?" the answer I expect is apparently YES?
Maybe MS's approach is, "nobody said no".
|
|
|
|
|
I'm with MS on this one: All is basically saying "If any of the people in this room do not match this condition return false"
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
There are certainly some odd decisions in the .NET class libraries. But I don't agree with you on this one. From a purely logical perspective, checking whether all members of an empty set satisfy a particular condition should always return true - there are no members which don't satisfy the condition, so returning false would be senseless.
If you want an example of a nonsensical decision, look no further than the System.Text.Json.JsonElement 's TryGet... methods, which will throw an exception if the "JSON type" of the element is wrong.
So TryGetInt64 will return true for { "id": 42 } ; return false for { "id": 3.1415 } ; and throw an exception for { "id": "42" } .
Given the usual TryParse pattern, you might expect these methods to return false for any invalid input. But that's not what they do. They return false for some kinds of invalid input, and throw an exception for other kinds of invalid input.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Would you think otherwise if the method were called Every ?
|
|
|
|
|
No.
Maybe its a mathematical mindset. "Is this condition true for every member of this (empty) set?" has to return true , since there are no members of the set where the condition is not true.
Similarly, "Is this condition true for any member of this (empty) set?" has to return false , since there are no members of the set where the condition is true.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I don't have a horse in this race, but I agree with your logic.
>64
Itβs weird being the same age as old people. Live every day like it is your last; one day, it will be.
|
|
|
|
|
You're not wrong.
But you're not right either.
Maths vs. Words
|
|
|
|