Forum Discussion
Some of this reminds me of an article Joe did years ago to test where the sweet spots were for if/else vs switch vs class matching.
https://community.f5.com/t5/technical-articles/comparing-irule-control-statements/ta-p/282675
Joe did some great work back then.
The only highly argueable part in his article is the conslusion, that [switch] is overall the best choice across the board.
His article did somehow not included a comparsion with just 1 or 5 items to compare. This is the area where [if] starts to shine. Beyond that scale [switch] will be undoubtedly the better choice.
When I started with iRules i've read Joes article and basically used [switch] everywhere. Took me a while to review my code and migrate back to [if] once I saw test results on TCL boards and did my own tests...
Over the years I've faced a couple guys who stricly followed this article and used also [switch] everywhere.... so it wasnt just me who followed his conclusion 😉
Cheers, Kai