I'm curious, which languages? I've never seen any of my colleagues write !!, ever, in C/C++, Java, Python, or Swift. I've also not seen it C# or Go, but my exposure is limited.
I've been paid to write code in Perl, PHP, Ruby, JS, Go, ObjC, and Java, plus a little C and Python, for going on 15 years. I'm pretty sure I've never written "!!" and I think I could count the times I've seen it used on one hand (maybe never in any codebase I've worked on, but I'm not entirely sure)
What? I've been coding in multiple languages for multiple platforms for almost 30 years and have never come across it. It seems rather unlikely that it's 'extremely common'
It is very common in C code, where for most of its history you hadn't any explicit boolean data type but used int, following the rule that zero is false and anything else is true.
The '!!expr' is the idiom most people use whenever the need for a canonical 0/1 representation arises.
WalterSear|8 years ago
joesb|8 years ago
People who only start coding for two weeks can't understand any code.
People who start has enough experience to work, but only start in this project for two weeks, will understand "!!" idiom.
debaserab2|8 years ago
prewett|8 years ago
ashark|8 years ago
xamuel|8 years ago
savanaly|8 years ago
GordonS|8 years ago
slrz|8 years ago
The '!!expr' is the idiom most people use whenever the need for a canonical 0/1 representation arises.