And talking about TIGSource again, this whole thread. It started as somebody asking how to check if a number was a multiple of 5, and it somehow devolved into people figuring out the most contrived way to solve that problem (...yes, myself included). There's some serious TDWTF-worthy material there.
Funniest line of code ever ?
This snippet comes courtesy of some healthcare related development I'm involved in:
if (staff.StaffType != null && !staff.Staff.StaffTypes.Any(st => st.StaffType.Id == staff.StaffType.Id))
staff.Staff.StaffTypes.Add(new StaffStaffType(staff.Staff, staff.StaffType));
StaffBO.Save(staff.Staff);
Reminded me of the "Spam Spam Spam..." Monty Python skit.
Think of how lonely you are if you're making programming jokes.
And think about how lonely you must be to troll forums with programming jokes. Just think about it.
Found this on TIGSource, and yes, it compiles and works as intended:
switch(mode) { case(0): if(test(a, b)) { case(1): result = foo(a, b); break; } else { case(2): result = bar(a, b); break; } }
Duff's device seems to use a similar mechanism to "jump" into a location of code.
[EDIT] Whoops, just saw that someone already linked that (indirectly). Oh well.
Except for the fact that Duff's device doesn't break through scope boundaries. Fair enough, with goto that's common, but at least there you expect that kind of stuff (especially since when goto is used it's normally to break away into an outer scope) but definitely not in a switch statement.
http://hg.icculus.org/icculus/lugaru/file/97b303e79826/Source/GameTick.cpp#l7276
^
This. All of them.
http://hg.icculus.org/icculus/lugaru/file/97b303e79826/Source/GameTick.cpp#l7276
^
This. All of them.
Wow. That's some bad code.
http://hg.icculus.org/icculus/lugaru/file/97b303e79826/Source/GameTick.cpp#l7276
^
This. All of them.
Wow. That's some bad code.
My brain definitely just hurt itself trying to read through all of that. it's completely indecipherable, like the lost language of an unknown civilization.
Comments really would have helped, but that...thing...is still very poorly designed!