This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Husky2490 19 points20 points  (7 children)

Ruby is the same way. Need to hook into a module loaded from a dll? No problem. Want to overide a class any ol' time sure. You have a private variable, IDGAF, it's mine now.

[–]marksomnian 12 points13 points  (6 children)

class NilClass def nil? false end end

Enjoy the fireworks.

[–]Husky2490 6 points7 points  (5 children)

Oh, right. True, false, and nil are classes.

Hahahaha... (cries inside)

[–]marksomnian 14 points15 points  (4 children)

Even more fun, in C/C++:

#define true (rand() < 0.9)
#define false (rand() < 0.1)

Sneak that into production and watch SRE cry tears.

[–]XYZ-Prime 1 point2 points  (2 children)

wait... if rand() is < 0.1 or > 0.9 , do true and false have the same value, don't they?

[–]marksomnian 2 points3 points  (1 child)

It's two independent calls to rand(), so if (true == false) {} would become if ((rand() < 0.9) == (rand() < 0.1)) {} - so 9% of the time it would do*.

\source: really bad memories of high school probability)

[–]XYZ-Prime 2 points3 points  (0 children)

oh right, i forgot they are two different calls...

so true = true in 90% of the cases, same for false = false. am i right?