The Ternary Operator and If-Else

By Dag, on December 30th, 2016

The ternary operator ":?" to make If/Else structures smaller and compact is a beautiful thing. Evaluate the following example and how it could be written in a much more compact and faster way. You can use this technique in several languages. I have personally used it during PHP, C and JavaScript development quite often.