One of the best comments I have found in a code base was "Ow magic numbers, guide us to the light!"
New forum - Coding Horrors
That must be like the first time a thread is four years older than the forum it's in.
if (x^2>0) then patato else tomato
is it supid enough for this new forum ? ^^
Sorry =)
This is stupid because the answer is always potato
Of course you can replace patato with tomato. If you prefer tomato. Do you like patato ?
Wrong. Your code is obfuscated way of checking if (x != 0)
I can't find the screenshot any more, but in one of my past companies, we had cool functions like this one:
int GetID()
{
return 4;
}
and this function would be overloaded for each and every object, with different (well, not always, as I noticed during debugging), typed by hand (sometimes commented // this ID is 4!) value.
Yay!
@Mantis
Yes, not great , let me elaborate :
optimistic version :
if (x==0) then else
pessimistic version :
if (x!=0) then else
Now it should make perfectly sense (cf ZE state of the art in term of conditional branch)
By the way, do you like boats ? (I'm about to create a poll on that)
#!/bin/bash
function f() {
sleep "$1"
echo "$1"
}
while [ -n "$1" ]
do
f "$1" &
shift
done
wait
example usage:
./sleepsort.bash 5 3 6 3 6 3 1 4 7
edit: removed link to source since it apparently has NSFW material that I didn't notice before posting.