---------- Forwarded message ----------
From: Edson Tirelli <ed.tirelli@gmail.com>
Date: 26/03/2007 15:06
Subject: Re: [rules-users] syntax question
To: Rules Users List <rules-users@lists.jboss.org>

 
   Michael,

   You got it right again.
   Just adding to your answer, the best way usually is to reorder the patterns as you did, having the collection as the last constraint, but it is also possible to use a predicate, instead of eval(), if you need to bind the collection earlier.
   Example:

Customer( $cars: cars )
Manufacturer( $m : name, ( $cars.contains( $m ) ) )


   []s
   Edson


2007/3/26, Anstis, Michael (M.) < manstis1@ford.com>:
Hi Bruce,
 
From my experience (with 3.1-M1) you can reference bound Facts/Columns in subsequent patterns; like:-
 
$m : Manufacturer ( name == "Honda" )
$c : Car ( manufacturer == $m )
$c : Customer ( cars contains $c, age > 18 )
 
$cars.contains("Honda") requires an eval statement as your requirement is equivalent to "Customer ( cars.contains("Honda") )" which does not use a zero-parameter field accessor and is not compliant with the Java Beans specification).
 
With kind regards,
 
Mike
 


From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Bruce leroy
Sent: 23 March 2007 18:20
To: rules-users@lists.jboss.org
Subject: [rules-users] syntax question

Hi,

I have a question regarding rules syntax particularly with left hand side. Suppose I have the following condition ..

when
   Customer ( $cars : cars, age > 18 )
...

How can I use the bind variable "$cars" in subsequent statements without using eval(), like so ...

when
  Customer ( $cars : cars,  age > 18 )
  eval( $cars.contains( "Honda" ) )
....


Basically I would like to know what the alternatives for doing something like so this without having to use eval function. I know this might not be the best example for this question, but please I'm just learning this system right now.


Thanks in advance,
Bruce.
  

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




--
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3124-6000
  Mobile: +55 11 9218-4151
  JBoss, a division of Red Hat @ www.jboss.com

--
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3124-6000
  Mobile: +55 11 9218-4151
  JBoss, a division of Red Hat @ www.jboss.com