- 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
A better solution would probably involve anonymous methods or lambda expressions.
<pendantry>By your count, only two people recognize that there may be a perfectly valid reason for doing something.</pendantry>
<just_plain_jerkiness>By my count, it's still zero.</just_plain_jerkiness>
Admin
Of course, to obtain "Test" you have to do: String[0.99999999] = "Test"
And now you have the evidence that 0.9999999 != 1.
Admin
Wow, that's a lot of CARCAP!
Admin
Best code I have ever seen! You are Hired!
Admin
terse is not the same as short. Have you ever tried to declare an
unsigned terse t;
in C? And there is no
#define terse short
in the standard headers either. What I suggest is something like this:
#define terse short #define gesticulated signed #define vaporific volatile
vaporific gesticulated terse t;
Try this in your own code and I promise its maintainers to be will love you.
Admin
seriously????
Admin
just thread in a noodle and jam it.
Admin
I'm not sure why people are so fond of anonymous methods. Just give it a good name and it's almost always clearer IMHO.
Admin
They're more succinct when used for one-line delegates.
Admin
Of course, if I try to be too clever and order a cheeseburger with -2 (negative two) patties, I will end up having to give them the 2 patties out of my own pocket as well as pay for a double cheeseburger.
Admin
I read this code for a moment and realised it was truely stupid; then I saw something deeper in it and realised that the idiot who wrote it needs, not to be shot, but --- actually I can not think of a punishment severe, painful and slow enough to inflict...OK then, make him listen to Celine Dion...
...I have a colleague who writes almost as bad code...that's isn't a compliment however...
Admin
Admin
I have never had a problem with C# not allowing this, I do however, wish that C# would equate null to false.
Customer cust = GetCustomerById(235); if (cust) { //yay! I saved time! }
Admin
Actually, all of those words have a meaning closer to "clear, but without wasted words".
Adding "== 0" is not "wasting" a word (it expresses the idea that what is being checked is the number 0, not the boolean false), and it improves clarity, therefore, while longer, the expression is more concise/succinct/terse.
Admin
10 FOR i=1 TO 10 10.5 PRINT i 10.1237843 NEXT i
Admin
Oh, so now we're talking about nondeterministic computing?
Sometimes a[0.5] returns a[0], sometimes a[1].
--Joe
Admin
I would suggest slightly different behavior so that the results are more continuous:
1: Test 2: Truncated 3: List
Strings[0] = "" Strings[0.5] = "Te" Strings[1] = "Test" Strings[1.00001] = "" Strings[1.22] = "Tr"
Admin
"Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration."
Admin
3 things:
Admin
This works for strings, numerics, and arrays:
I expect I could write it more succinctly, but it works....
Admin
For numeric values, I would expect the entries represent known points in a function.
points[-1.0] = 5.8 points[ 0.5] = -1.9 points[10.2] = 8.5
Then points[0.0] is an interpolation between (-1.0, 5.8) and (0.5, -1.9).
E.g. simplest linear interpolation:
a = (y2 - y1)/(x2 - x1) b = ((y2 - a * x2) + (y1 - a * x1)) / 2 return a * x + b;
Can use linear, polynomial, cubic spline, etc. interpolation.
Admin
return !myList.Any();
Admin
I always feel that that method should return a random element from the list rather than a boolean.
Admin
+1
Admin
FTFY
Admin
bwe-e-erp, glug, splash.
Admin
Fuck that... I don't want this clown making my QPWC. He'd probably dip it in mop bucket water first.
Admin
Ooh, Celine Dion! My favorite wallpaper!
Admin
Squirted coffee through nose, fortunately missing keyboard but drenching cat.
Admin
FTFY (portability)
Admin
Even in a non-garbage-collected language, a similar argument can apply, such as with C++'s list::splice function.
Admin
Noting that it's even more readable, and shorter yet.
Admin
And you can use local variables
Admin
I want to cry. I seriously want to cry. I can feel the tears forming in my ducts, ready to stream out.
Admin
this broke my mind....
Admin
I wish this was only a joke, but I've seen it too often in real production code (no longer than last week in fact)
Just a little mistake though, usually people who write that don't use advanced uber techniques like "IndexOutOfRangeException" but just stick to "Exception"
Admin
Please please please tell me we don't fight holy wars over VB.
Admin
Except that you erroneously negate the result. :P
Admin
If you can teach him to keep his bodily fluids off the food then the patties will be unsigned.
Admin
[quote user="pbean Kudos to the first to implement a TruncatedList collection class where you can index with floats and it somehow cuts the elements in pieces[/quote]
At least he should have the decency to name it HideousList. What in the name of Hades...
Admin
public bool isCommentFrist(IList<Comment> listofComments) { if (listOfComments.Count >= 1) { return false; } else { return true; } }
CAPTCHA: conventio
... almost convention but not quite.
Admin
Or just mail him a link to TheDailyWTF.com, and hope that it gives him a few hints on how NOT to code, rather than giving him even more "clever" ideas.
Admin
The pattern I recognize here is "on the job self-training".
This person was obviously hired into a job (s)he doesn't know how to do, so the only way out of it (except resignation) is to try and learn. And an easy way to do that is writing wrappers around existing functionality and calling them, or tweaking existing code just a little bit, and see what happens.
I find myself doing that when I'm faced with a code base I don't know. I start refactoring, systematic rewrites, and adding wrappers, to make the code clearer and easier to use. The end result may not in fact be clearer or easier for another programmer but it will be for me because I have now ploughed through the whole code base and learnt what everything means. It's a process of digestion. We're seeing the same thing here.
Admin
Recommend to add some security code.
Admin
Admin
And you are missing the Scr1pT K1dD13s which mix upper- and lowercase. :)
Admin
IsBrillanterThanOne
Admin
Unfortunately, what we have here is the very final stage of digestion.
Admin
Actually, you can, assuming that your project allows you to use Visual Studio 2008 targeting .NET Framework 2.0.
It's true that the ExtensionAttribute used by the compiler to note extension methods is within System.Core.dll, which is a part of .NET Framework 3.5. However, the C# 3.0 compiler doesn't actually confirm where the attribute exists, only that it does exist. By defining an attribute of the same namespace and name within your project you can use extension methods freely:
Admin
BRILLANT!