[rules-users] Trivial rule with condition in RHS won't compile, help please

CK chrisckc at gmail.com
Thu Dec 3 14:49:32 EST 2009


I would assume that you're trying to test out rule writing and see  
what works and what doesn't.   I don't believe you can use if  
statements in the RHS.

Normally, anytime you want to use "if" statements inside the RHS, it's  
a sure sign that you should move it to the LHS and create separate  
rules.

You can actually make your rule even simpler:

rule "test"
dialect "mvel"
when
   //empty LHS automatically implies true
then
   System.out.pritln("***")
end

Cheers,
Chris

On Dec 3, 2009, at 11:43 AM, Barry Kaplan wrote:

>
> The following rule:
>
> rule "test" dialect "mvel"
> when
>    eval(true)
> then
>    if (true) {
>        System.out.println("***")
>    }
> end
>
> Fails with:
>
> java.lang.RuntimeException: Unable to build expression for  
> 'consequence':
> was expecting type: java.lang.Object; but found type: void '    if  
> (true) {
>        System.out.println("***")
>    }
>    true
> ' : [Rule name='test']
>
> I can't for the live of me figure out what mvel is bitching about.
>
> Note that the following does compile:
>
> rule "test" dialect "mvel"
> when
>    eval(true)
> then
> //    if (true) {
>        System.out.println("***")
> //    }
> end
> -- 
> View this message in context: http://n3.nabble.com/Trivial-rule-with-condition-in-RHS-won-t-compile-help-please-tp67458p67458.html
> Sent from the Drools - User mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list