Funniest line of code ever ?

Started by
125 comments, last by Orymus3 9 years, 2 months ago

When I was teaching someone to code, I had a hard time explaining why


if(Button == 200 || 300){

} 

didn't check if the variable was equal to at least one of the variables as if it were


if(Button == 200 || Button == 300){

}

The exact language was "Expression 2" if anyone was wondering. It's a thing for a game called "Garry's Mod".

Advertisement

When I was teaching someone to code, I had a hard time explaining why


if(Button == 200 || 300){

} 

didn't check if the variable was equal to at least one of the variables as if it were


if(Button == 200 || Button == 300){

}

The exact language was "Expression 2" if anyone was wondering. It's a thing for a game called "Garry's Mod".

When I was trying to teach somebody to code they wanted to use 'or' to randomly pick between two numbers


value = 1 or 2

Its understandable how a non programmer would expect this to work, so I didn't think he was dumb for doing it, but I still found it funny.

My current game project Platform RPG


When I was trying to teach somebody to code they wanted to use 'or' to randomly pick between two numbers
value = 1 or 2
Its understandable how a non programmer would expect this to work, so I didn't think he was dumb for doing it, but I still found it funny.

I remember trying to do the same thing myself when I was learning c++.

Stay gold, Pony Boy.


When I was trying to teach somebody to code they wanted to use 'or' to randomly pick between two numbers
value = 1 or 2
Its understandable how a non programmer would expect this to work, so I didn't think he was dumb for doing it, but I still found it funny.

I remember trying to do the same thing myself when I was learning c++.

You should be able to do something like that with variadic templates, though... make a proper templated class, and a function helper to simplify the syntax, and you should be able to do akin to:


if (multi(foo, bar, 4) == some_var) ...

public static DateTime getTommorowsDate()
{
    Thread.Sleep(24*60*60*1000);
    return DateTime.Now;
}

public static DateTime getTommorowsDate()
{
    Thread.Sleep(24*60*60*1000);
    return DateTime.Now;
}

I think Baby Jesus just cried.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.


int length= 0;
 for(int idx = 0; idx < a.length; i++){
      length++;
  }
?System.out.println("length is : " + length);

Some Java code to get the length "cough" of the array 'a'. Nice!

I think, therefore I am. I think? - "George Carlin"
My Website: Indie Game Programming

My Twitter: https://twitter.com/indieprogram

My Book: http://amzn.com/1305076532

int length= 0; for(int idx = 0; idx < a.length; i++){      length++;  }?System.out.println("length is : " + length);
Some Java code to get the length "cough" of the array 'a'. Nice!
See i could kinda understand someone doing this with a c++ iterator, but come on, was the programmer going "well if i go through the length of the array and count up then i'll get the length of the array!"

Edit: aldo nice infinite loop in there =-P
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.


int length= 0; for(int idx = 0; idx < a.length; i++){      length++;  }?System.out.println("length is : " + length);
Some Java code to get the length "cough" of the array 'a'. Nice!
See i could kinda understand someone doing this with a c++ iterator, but come on, was the programmer going "well if i go through the length of the array and count up then i'll get the length of the array!"

Edit: aldo nice infinite loop in there =-P

So that you can avoid unnecessary code duplication, why not put this in a function?

int getIntegerValue(int n)
{
    int ret = 0;
    for(int i = 0; i < n; i++) {
        ret++;
    }
    return ret;
}
 
System.out.println("length is : " + getIntegerValue(a.length));

Work smarter, not harder.

This topic is closed to new replies.

Advertisement