Originally Posted by PhotonFanatic
New python question. I'd like to hear what you guys have to say on this:
Why does elif
The way I understand it, it goes like this: if (some function), do this.
Else, do this. Why would elif
be needed? Wouldn't it make more sense to just be able to use an infinite number of elses?
if [ hour < 12 ]
echo "good morning"
else if [ hour > 12 && hour < 18 ]
echo "good afternoon"
echo "good evening"
Like the above code, sometimes you need more decision making. I made a workflow for a job and I had 5 else if statements in a row and finally an else. The reason was I needed to make sure that my final decision (the else) had passed a bunch of safety checks. If all of the else if statements returned false then I knew it was safe to proceed with the else, otherwise the else if statement would return a failure error.