this post was submitted on 08 Dec 2023
573 points (96.1% liked)
Programmer Humor
32410 readers
1 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Perl has both
$a || $band$a // $b.The
||version is older and has the value of$bif$ais any false value includingundef(which is pretty much Perl'snull/nil).The
//version has the value of$biff$aisundef. Other "false" values carry through.Ruby took both "no
returnrequired" and "no final semicolon required" from Perl (if not a few other things), I think, but it seems that//was Perl later borrowing Ruby's||semantics. Interesting.i.e.
0 || 1is1in Perl but0in Ruby. Perl can0 // 1instead if the0, which is a defined value, needs to pass through.