Forum Discussion
iRules command: Switch vs If
- Oct 06, 2020
Yes Morris. That's right.
If-statement with 3 conditions (and default).
if { $bla eq "one" } { # do something } elseif { $bla eq "two" } { # do something } elseif { $bla eq "three" } { # do something } else { # do something }
Switch-statement with 3 conditions (and default).
switch $bla { "one" { # do something } "two" { # do something } "three" { # do something } default { # do something } }
Don't forget to mark my answer as the best the help me for the contribution.
Regards,
Dario.
hmm, quite interesting article.
So, basically a switch statement with 1 or 2 conditions won't make much difference than if-else statement but more than 5 "switch statement" would be a better choice. Am I understand correctly?
Any example code for a switch statement with 5 conditions?
- Oct 06, 2020
Yes Morris. That's right.
If-statement with 3 conditions (and default).
if { $bla eq "one" } { # do something } elseif { $bla eq "two" } { # do something } elseif { $bla eq "three" } { # do something } else { # do something }
Switch-statement with 3 conditions (and default).
switch $bla { "one" { # do something } "two" { # do something } "three" { # do something } default { # do something } }
Don't forget to mark my answer as the best the help me for the contribution.
Regards,
Dario.
- morrisOct 07, 2020Nimbostratus
Thanks!
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com