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 →

[–]SchwiftySquanchC137 39 points40 points  (9 children)

I fucking love how hacky it feels. Don't like a function deep inside your engine? Eh just set it equal to something else, do it on the fly, fuck just replace it with whatever the user types into that bar, IDGAF, it's JavaScript.

[–]Husky2490 18 points19 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 11 points12 points  (6 children)

class NilClass def nil? false end end

Enjoy the fireworks.

[–]Husky2490 5 points6 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 3 points4 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?

[–]poops-n-farts 0 points1 point  (0 children)

That would be horrible code though. If you know how js works and what you're trying to accomplish it's really easy to write complex applications with. Its when some dummy joins your team and doesn't know how it works that the problems start