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

Greg Barton greg_barton at yahoo.com
Thu Dec 3 15:01:31 EST 2009


You can use them in the RHS, but just with java dialect. The RHS code should then be passed through with no modification.

And there are occasional reasons why you would want to test conditions in the RHS (optimization, mostly) but should be avoided most of the time.

--- On Thu, 12/3/09, CK <chrisckc at gmail.com> wrote:

> From: CK <chrisckc at gmail.com>
> Subject: Re: [rules-users] Trivial rule with condition in RHS won't compile, help please
> To: "Rules Users List" <rules-users at lists.jboss.org>
> Date: Thursday, December 3, 2009, 1:49 PM
> 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
> 
> _______________________________________________
> 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