I was using ArrayList before and I don't think this is the real problem. collect() will return object compatible with List interface so it is valid to use size() and get() methods on $removeUs.<div>I have helper method myhelper.log() with accepts any object and <b>myhelper.log($removeUs.get(i))</b> works for me, unfortunately <b>retract($removeUs.get(i)) </b>doesn't work with error:</div>
<div><br></div><div><font color="#333333" face="arial, tahoma, verdana, sans-serif"><span style="font-size:14px">Error: unable to resolve method using strict-mode: org.drools.spi.KnowledgeHelper.drools()] [Near : {... drools.retract($removeUs ....}]</span></font></div>
<div><br></div><div>It looks like it is not even compiled.</div><div><br><div class="gmail_quote">2012/11/30 Wolfgang Laun <span dir="ltr"><<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 30/11/2012, Martin Minka <<a href="mailto:martin.minka@gmail.com">martin.minka@gmail.com</a>> wrote:<br>
> Thank you for the tip. What solution would you suggest to solve my problem<br>
> ?<br>
<br>
Look into the javadoc of java.util to find any class implementing List :-)<br>
-W<br>
<br>
><br>
> Martin<br>
><br>
><br>
> 2012/11/30 Wolfgang Laun <<a href="mailto:wolfgang.laun@gmail.com">wolfgang.laun@gmail.com</a>><br>
><br>
>> You cannot use an interfact (List) to instantiate an object, which<br>
>> is happening due to the collect.<br>
>> --W<br>
>><br>
>> On 30/11/2012, Martin Minka <<a href="mailto:martin.minka@gmail.com">martin.minka@gmail.com</a>> wrote:<br>
>> > I want to keep only 1 fact with id=="aaaa". But this is not working:<br>
>> ><br>
>> > rule "leave only one"<br>
>> > when<br>
>> > $removeUs : java.util.List(size>1)<br>
>> > from collect(Fact(id=="aaaa")<br>
>> > then<br>
>> > size = $removeUs.size();<br>
>> > for (int i=1; i < size; i++) {<br>
>> > retract($removeUs.get(i));<br>
>> > }<br>
>> > end<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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
>><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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br></div>