Let's play a little game. Who has seen the most ridiculous set of conditions within the parentheses of an if
statement?
Trigger Warning 😡
Before commenting, please know I understand there are developers out there who hate if
statements with a passion. If you are such a developer, please stay away to avoid needing heart medication and/or a psychological examination.
Now, getting back to our little game...
The rules 📖
- Only what's within a single set of outer parentheses of an
if
statement counts- JS example:
if ( condition ) {
- JS example:
- If parentheses aren't required for your language of choice, then everything after the
if
and before the terminating character counts- e.g., BASH
if
statements wrap individual conditions in sets of parentheses or brackets, so they also count. if [ -r $1 ] && [ -s $1 ]; then
- e.g., BASH
- You can't count multiple sets of statements from something like an
if...elseif...else
. In cases like those, only use the set of conditions from a singleif
orelseif
. - In this case, I'm not counting multiple parts joined by conditional operators as a single condition. Everything between conditional operators is counted individually.
- This refers to operators such as
and
,or
,||
,&&
and any others your language uses.
- This refers to operators such as
- The character count I'm giving is exact because it's in front of me. If you can't pull it up immediately, it's ok to estimate. But please do estimate as close as you can.
One last note 📝
Honestly, I'm not sure if I'm using the word "condition" incorrectly here. Should I be using the word "expression" instead? This part of dev grammar is a little fuzzy to me.
With all of that out of the way, let the brain hemorrhaging commence. 😵🧠
My entry: 18 conditions and 619 characters long.
I'm also including the actual statement, for anyone curious. I've added line breaks in some places to make it somewhat easier to read, but it was originally all on 1 line.