I have the following in my global block:
test = defaction(){
    if(5>10) then {
        notify("yes","yes");    
    }
}
Then I also have the following rule:
rule tester {
    select when pageview ".*"
    test();
}
I am expecting that the notify will never happen, as 5 will never be greater than 10. However, it runs on every single page. I am sure that I am doing it wrong, although i开发者_StackOverflow社区t feels right.
Predicates (such as if (5>10) then are not part of the action block. As such, including predicatees in a defaction doesn't make sense. You'll have to write it more like this:
global {
    test = defaction(){
        notify("yes","yes");    
    }
}
rule tester {
    select when pageview ".*" setting ()
    if (5>10) then {
        test();
    }
}
The if...then construct fulfills the same function as, say, the every construct: it wraps the action block.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论