You have absolutely nothing
<?php
well hello there again
?>
to worry about. If PHP existed
we would have sophisticated
<?php
I trust that life has
been treating you well?
?>
methods of detecting it, and
it would pose literally no
<?php
Don't open the door. It's me.
?>
threat to anyone.
Because it's not one. Ternary operator is A ? B : C, Elvis operator is A ?: B. The same two characters are involved, but both the syntax and effect is different.
27 Comments
Blue_Morpho@lemmy.world · 45 pts · 1y
I never heard it called the Elvis operator! Thanks!
lord_ryvan@ttrpg.network · 28 pts · 1y
It's because if you turn it 90° to the right, it looks like Elvis' hair with two eyes underneath!
disguy_ovahea@lemmy.world · 22 pts · 1y
I saw it the other way, with the question mark as the curl of his lip.
dwemthy@lemdro.id · 9 pts · 1y
Mfw I'm checking for null
cobysev@lemmy.world · 3 pts · 1y
?:)
pogodem0n@lemmy.world · 1 pts · 1y
Holy shit
MyNameIsRichard@lemmy.ml · 5 pts · 1y
It was called Elvis back when it was a smiley
deathmetal27@lemmy.world · 13 pts · 1y
Kotlin user spotted
DeprecatedCompatV2@programming.dev · 3 pts · 1y
(run { this@comment.parent?.apply { this.value === true } } == true) ?: if ((this@comment.value as? Boolean) != true) false else true
QuazarOmega@lemy.lol · 3 pts · 1y
php too
..but we don't talk about php
Sleepzy@feddit.it · 2 pts · 1y
php doesn't exist, php can't hurt you
tetris11@lemmy.ml · 3 pts · 1y
fxdave@lemmy.ml · 2 pts · 1y
aah my favorite template engine, I have seen it so long ago
QuazarOmega@lemy.lol · 1 pts · 1y
Oh unfortunately these imaginary pains are those which hurt every day
silasmariner@programming.dev · 2 pts · 1y
Nobody's assuming Groovy these days then 😂
chunkystyles@sopuli.xyz · 2 pts · 1y
I've been working in Jenkins pipeline for a while now.
Why the fuck is Groovy?
silasmariner@programming.dev · 1 pts · 1y
Well Grails didn't stick around for long, but Gradle was only available with Groovy for many years before they added Kotlin support.
bl4kers@lemmy.ml · 12 pts · 1y
I don't understand this. Small brained users rise up
QuazarOmega@lemy.lol · 12 pts · 1y
On the left you have Elvis Presley, while on the right there's the so-called Elvis operator
AVincentInSpace@pawb.social · 3 pts · 1y
why would you call it anything other than the ternary operator
dev_null@lemmy.ml · 3 pts · 1y
Because it's not one. Ternary operator is A ? B : C, Elvis operator is A ?: B. The same two characters are involved, but both the syntax and effect is different.
AVincentInSpace@pawb.social · 2 pts · 1y
The second one isn't valid syntax in any programming language I'm familiar with. What does it do?
dev_null@lemmy.ml · 4 pts · 1y
It's a shorthand for writing this:
This is equivalent:
AVincentInSpace@pawb.social · 2 pts · 1y
Huh. Neat feature. That's in C# I assume?
dev_null@lemmy.ml · 2 pts · 1y
It's in Kotlin and some other languages. C# has it but there it's actually
A ?? B.QuazarOmega@lemy.lol · 2 pts · 1y
Read further down on my other comment to understand, it's just how the operator looks
NicKoehler@feddit.it · 3 pts · 1y
Same