Funniest line of code ever ?

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

I saw this appropriately named function in a game:

ejectShitFromMyAssAndDie()

It did what I expected it to do.

Advertisement

From a Kinect Game i was refactoring.

The level had a fixed size and you were moving through kind of a tube, only capable of strafing and adjusting your speed.


Player.Score += (int)(60f * Player.Velocity.Length() * gameTime.GetDelta());

Blog: http://www.julianloehr.de

Twitter: https://twitter.com/jloehr_gamedev

HID Wiimote - Windows Device Driver for Wii Remote & Wii U Pro Controller: http://julianloehr.de/educational-work/hid-wiimote/

"Equal to" and "of the same type" ... bit redundant .

Maybe, but at least that prevents surprises from numerical conversions and weird interactions between $pass and the string if $pass is some other type. It gets really screwy:

http://php.net/manual/en/types.comparisons.php

I don't remember if it was === or == actually, it could have been ==, it was long ago and that person wasn't a programmer.

My favorites are always static analyzer stuff. Frequently annotated with "//to shut up the static analyzer". I can't think of any recent examples though.

I knew a guy who wrapped some code that would never be reached in:


if (superman > batman){
//some code
}

biggrin.png

I have once seen a junior colegue of mine do a gentle modification


if (l.code==86)

{

 ....

}

// jan grubenar #

if (l.code==86)

{

....

}

// jan grubenar *

after a little chit chat he resulted into


if (l.code==86)

{

 ....
// jan grubenar #  (please do not write after this code but before it!)
....
// jan grubenar *
}


(this is rather not exact but it shadely describes it)

I think by now I want a version of C++ that doesn't do any automatic type conversions at all. !0 is the int 1, and you shouldn't be allowed to assign that to a char without an explicit cast.


Without any implicit conversions then !0 wouldn't compile either since ! is a logical operator (not a bitwise operator) and integers are not booleans. Likewise, "if(i)" (where i is an integer) should be an error instead requiring the explicit "if(i!=0)" if you want to be strict about conversions.

I'm not saying that the idea is bad (I hate implicit conversions myself, too) just pointing out the ramifications of no implicit conversions. You seem to rely on them more than you think. smile.png

Also note that outright banning implicit conversions would also mean that conversions to references would be disallowed or from non-const/volatile to const/volatile or back though I'd assume you meant to give those implicit conversions a pass. smile.png

Sean Middleditch – Game Systems Engineer – Join my team!

I have once seen a junior colleague of mine do a gentle modification


if (l.code==86)

{

 ....

}

// jan grubenar #

if (l.code==86)

{

....

}

// jan grubenar *

.

This person did not know what a while loop was ?

.


boolean run = true;

while (run){
     if (l.code == 86){
          //do stuff
     {
  {

I cannot remember the books I've read any more than the meals I have eaten; even so, they have made me.

~ Ralph Waldo Emerson

I think by now I want a version of C++ that doesn't do any automatic type conversions at all. !0 is the int 1, and you shouldn't be allowed to assign that to a char without an explicit cast.


Without any implicit conversions then !0 wouldn't compile either since ! is a logical operator (not a bitwise operator) and integers are not booleans.


True!


Likewise, "if(i)" (where i is an integer) should be an error instead requiring the explicit "if(i!=0)" if you want to be strict about conversions.


That seems desirable to me.


Also note that outright banning implicit conversions would also mean that conversions to references would be disallowed or from non-const/volatile to const/volatile or back though I'd assume you meant to give those implicit conversions a pass. smile.png


There is no implicit conversion back from const/volatile to non-const/volatile.

And yes, I meant to give those other implicit conversions a pass.


That seems desirable to me.
Not really. I have a scripting language where the only implicit casts allowed are: derived->base or pointer-compare-to-null. Notably, integers don't auto convert to bools. It stings me regularly every time I compile something with an if(integer) inside. It's not just a matter of being used to C/C++ autocasting feature. It's just more compact notation.

Previously "Krohm"

This topic is closed to new replies.

Advertisement