I don’t understand this. Small brained users rise up
On the left you have Elvis Presley, while on the right there’s the so-called Elvis operator
been programming since 2008. the fuck is an elvis operator?
Been programming since the 80s, ditto.
Ternary if?then:else
gotacha. i’ve only ever heard them called ternaries. maybe i’m old. maybe i’m too young. definitely one of the two
It specifically refers to this shorthand
?:
that works like this:$value = $thing_that_could_be_truthy ?: 'fallback value'; # same as $value = $thing_that_could_be_truthy ? $thing_that_could_be_truthy : 'fallback value';
The condition is also the value if it is truthy
I never heard it called the Elvis operator! Thanks!
It’s because if you turn it 90° to the right, it looks like Elvis’ hair with two eyes underneath!
I saw it the other way, with the question mark as the curl of his lip.
Mfw I’m checking for null
?:)
Holy shit
It was called Elvis back when it was a smiley
Kotlin user spotted
php too
…but we don’t talk about php
php doesn’t exist, php can’t hurt you
Oh unfortunately these imaginary pains are those which hurt every day
Nobody’s assuming Groovy these days then 😂
I’ve been working in Jenkins pipeline for a while now.
Why the fuck is Groovy?
Well Grails didn’t stick around for long, but Gradle was only available with Groovy for many years before they added Kotlin support.
(run { this@comment.parent?.apply { this.value === true } } == true) ?: if ((this@comment.value as? Boolean) != true) false else true
Same