Thanks, I'll do that. In the meantime I still need to get the job done asap. Can you provide me an example to implement such a logic using an inline-eval and global (which variable should be  global?)? And just out of curiosity can you explain me why this code doesn't work (basically why, after the second line, $myList.contains($myObject) would return false):
<br>&gt; $myList : List() from collect( MyObject(myField == &quot;something&quot;) )<br>&gt; $myObject : MyObject() from $myList<br>&gt; eval( $myList.indexOf($myObject) &lt; 3 )<br>To me, this code seems to be just fine (in real Java it would be), so I can&#39;t understand why it doesn&#39;t work here. Maybe I am missing something or the DRL-Java code mapping done by a rule compiler is not so simple to figure out.
<br><br>Regards,<br><br>CG<br><br><div><span class="gmail_quote">On 8/8/07, <b class="gmail_sendername">Mark Proctor</b> &lt;<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
There is no supported way to do this. You could use an inline-eval<br>against a global, but that is very clunkey. However it does seem like a<br>good feature idea for a future release, open a jira and I&#39;ll look into<br>
getting it included.<br><br>Mark<br>pentarious wrote:<br>&gt; Does anyone know a method to limit the number of results from a collect<br>&gt; statement? I was just wondering how to do something like this:<br>&gt; $myList : List() from collect( MyObject(myField == &quot;something&quot;) ) limit 3
<br>&gt; //it should put in $myList just the first 3 objects retrieved<br>&gt; I&#39;m quite sure there is nothing in Drools which can natively support<br>&gt; something like that. So, how to do that, if needed? I tried this, but it
<br>&gt; seems not to be working (I can&#39;t understand why, though):<br>&gt; $myList : List() from collect( MyObject(myField == &quot;something&quot;) )<br>&gt; $myObject : MyObject() from $myList<br>&gt; eval( $myList.indexOf($myObject) &lt; 3 )
<br>&gt; Indeed, it doesn&#39;t work because the link beetween $myList and $myObject<br>&gt; seems to be released during any execution of the rule (In fact<br>&gt; $myList.contains($myObject) returns false! Again, I can&#39;t understand why...)
<br>&gt;<br>&gt; Any advice would be really appreciated!<br>&gt;<br>&gt; Regards,<br>&gt;<br>&gt; CG<br>&gt;<br><br>_______________________________________________<br>rules-users mailing list<br><a href="mailto:rules-users@lists.jboss.org">
rules-users@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote></div><br>