Monday, February 28, 2011

The existential crisis of a method

Was doing some coding in C#, came across a method named Intersects with the return type of ...float?

float? Ray.Intersects(BoundingBox box)

Now what is that crap? Is it really too much to ask that a method in a typed language be precise about its goddamn types? If I wanted to deal with that kind of wishy washy bullshit I'd go whip up a PHP page. I need my floats floaty and my ints inty and I sure as hell don't need my methods going through some kind of existential crisis. Get your shit together, Ray.Intersects.






Aaaaaand just for the record the question mark indicates the type is nullable. Where floats normally can't be null, if you slap a little question mark on there you can null it out to your heart's content. Which is actually somewhat practical and not very funny at all.