- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
Admin
Hmmm... I've never heard of IList<T>.Any() before.
Admin
I think we just saw tomorrow's WTF.
(Implicit conversion of ints to bools - shudder)
Admin
If by "sane", you mean "confuses boolean and numerical values", then I agree.
Admin
Good lord man, quiet! You start giving ideas, and soon we'll find a tard actually finding a way to code that kind of stuff :/
Admin
Win.
Admin
If you have to assume anything to know whether it's going to work, it's generally a worse idea than using something guaranteed, or at least more likely, to be unambiguous.
You are not more clever or more efficient using !var over a comparison operator that explicitly indicates what you are trying to do.
Admin
Just use the null coalesce operator "??". ^^ (Although you can't use that in every situation, I admit).
Admin
As others have mentioned C and C++ permit this as it treats any non-zero value as true. The designers of C# explicitly don't permit this because a simple typo can result in a successful compilation that could be troublesome to debug:
This is also why C# doesn't permit fall through between cases in a switch block unless that case is empty, unless you goto that case label, which is kinda wonky.
Admin
No way. She was a 0.7, tops. Maybe 0.8 if she got rid of those bangs.
Admin
It's a LINQ extension method on IEnumerable.
Admin
Defined in System.Linq.Enumerable.
There's also an override taking a Func<TSource,bool> predicate.
Admin
The reason this happens is Intellisense auto-correction of mistyped variable names. If you misspell a symbol when defining it, then attempt to spell it correctly elsewhere, the IDE "helpfully" changes it to the incorrect spelling. If you're coding fast, you might not notice it happening because the editor keeps "correcting" you.
We have a function in a product here called UpdataGrid(). It's supposed to be UpdateGrid(). It's impossible to believe that somebody would deliberately type "Updata" zillions of times without freaking out and fixing it.
I love Intellisense in other ways, but this particular thing pisses me off.
Admin
Is that an extension method for IEnumerable? I don't usually write code against anything after framework 2.0 because we always end up having to be backward compatible to Win2k. Thus, no linq.
Sorry, my bad.
Admin
I think they really explicitly permit implicit conversion, not really bool/int.
Btw, a point for not doing those insane bool-value-to-literal-comparisons:
or similarly
Admin
Wait, shouldn't 10.1237843 come before 10.5? Uh oh.
I think the original function name works better if read with a Scottish accent: "Och, is list connt smalle' tha' one, lad? If no', yer doolally!"
Admin
Schrodinger's Index.
CAPTCHA: secundum ("The secun time I read this, it was still dum.")
Admin
Gives me hope that I can get a job one day. I used to think all developers were geniuses.
Admin
And if you ever land a job as a programmer you are gonna look back on that time and long that it really was like that. The worst part about this line of work is the beancounters tied with the fucktarded twats that couldnt code their way out of paper bag. They seem to not like me since I started reading code all the time and pointing out their mistakes and stupidities. Wish someone did it with my code too. >.< We all produce some wierd code at times.
Admin
Sure, as C# still borrows from C and C++ that = is always the assignment operator, the result of an assignment is the value of the assignment, assignments can be compounded and comparisons can work against any expression. The only thing that C# does differently is not allow those comparisons to work against anything that isn't boolean, can't be implicitly cast to boolean or doesn't overload true/false operators.
So sure, it won't stop 100% of the bugs that might result in unintentionally comparing against an assignment, but it does severely limit the circumstances under which it is permitted. Such assignment/comparisons are completely legal and might be intentional, although such a practice is probably not a good idea and maybe worthy of a compiler warning.
Admin
Never coded in C# myself - is accepting lists by value instead of a reference a common practice there ?:)
Admin
Yes. The only thing being passed by value is the reference, which is similar to a pointer. So unless the method is actually changing the object the reference points to, there is no need to pass by reference.
Admin
Admin
What if it's 'FileNotFound'?
Admin
This may actually be helpful in debugging, if say, you want to put a breakpoint no either one of the branches.
Admin
Stop it!!!
My brain hurts now.
Admin
Unfortunately the problem stems from the fact that a lot of 'programmers' aren't really programmers... they're coders. These are the same fools that stay in the same job forever while the rest of us professionls that actually know what we're doing move on to bigger and better places.