this post was submitted on 05 Sep 2023
913 points (98.7% liked)

Programmer Humor

19594 readers
1014 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] seitanic@lemmy.sdf.org 37 points 1 year ago (3 children)
[–] zqwzzle@lemmy.ca 19 points 1 year ago (1 children)
[–] luciferofastora 1 points 1 year ago

For those unfamiliar with the magic behind this, the rough outline goes like this:

++ is an operator to increment a number.
The string 'a' can't be incremented, because it's not a number.
++'a' thus evaluates to NaN (Not a Number), which in turn is converted to the string 'NaN'.

The string concatenation expression is thus equivalent to 'b' + 'a' + 'NaN' + 'a' which evaluates to 'baNaNa' and is then lowercased to 'banana'.

(You could get more pedantic about the exact evaluation mechanisms and order, but if you're proficient enough to make sense of that, you probably didn't need the explanation in the first place)

[–] fraction@feddit.de 9 points 1 year ago

Based on this you can Take Shit even further with jsfuck

[–] StarkillerX42@lemmy.ml 3 points 1 year ago* (last edited 1 year ago) (1 children)

"Actually, this one isn't 'Wat', it's part of what makes Ruby awesome and powerful, unless of course you actually do this, at which point it's 'Wat'"

[–] Zeragamba@lemmy.ca 3 points 1 year ago* (last edited 1 year ago)

let's talk about Ruby

Ruby like most programming languages doesn't support bare words, [undefined variable exception]

but if you define a particular method_missing, suddenly Ruby supports bare words. [ruby repeating what was typed]

Now this isn't deserving of wat. this actually shows just how awesome Ruby is. [Drummer_t-rex.jpg]

But if you actually do this then....

Wat