Forum Discussion

Robert_47833's avatar
Robert_47833
Icon for Altostratus rankAltostratus
Jul 21, 2011

closing brackets before "else"

Hi,dear Irule

 

 

if {[class match $uri starts_with gen3abURLs_SRWD29]} {

 

if { rand() <0.2 } {

 

pool cjj-BRX set cjjA_cookie 1

 

return

 

}

 

else {

 

pool cjj-BROWSE

 

set cjjB_cookie 1

 

return

 

}

 

}

 

 

Hi,in a http request event,if I submit rule like above,it told me undefined procedure :else

 

 

but if I changed it to rule like below,it is fine,why should I put else after the closing brackets,how to work around this?

 

if {[class match $uri starts_with gen3abURLs_SRWD29]} {

 

if { rand() <0.2 } {

 

pool cjj-BRX

 

set cjjA_cookie 1

 

return

 

} else {

 

pool cjj-BROWSE

 

set cjjB_cookie 1

 

return

 

}

 

}

3 Replies

  • Doctor it hurts when I do this!

     

    Don't do that :)

     

     

    See unRuleY's post here for details:

     

    http://devcentral-llix.f5.com/Community/GroupDetails/tabid/1082223/asg/50/aft/8042/showtab/groupforums/Default.aspx

     

     

    Aaron

     

     

  • Haha

     

    it is too long

     

    After delete the white space after } which is before "else",it can be submitted
  • If you don't care to much about readability.. you could leave it out...

     

     

    "The then and else arguments are optional "noise words" to make the command easier to read."

     

     

    http://devcentral.f5.com/Tutorials/TechTips/tabid/63/articleType/ArticleView/articleId/124/iRules-101--02--If-and-Expressions.aspx