[rules-users] Can get "not equal" (!=) to work but not "equal" (==) in LHS

Stephen Masters stephen.masters at me.com
Tue Feb 5 12:21:19 EST 2013


Going by the example provided, the code is a constraint on the left hand side … so it's valid to use == or !=. It's not Java code, it's MVEL and is automatically converted to use the appropriate .equals("") method on the Java objects.

You would only need to use .equals("") inside an eval or in Java code on the RHS.

So the answer is something else … but I haven't worked out what yet. :)

Steve


On 5 Feb 2013, at 17:11, rjr201 <rich.j.riley at gmail.com> wrote:

> It may be because in Java you have to compare strings using .equals("");
> 
> So in your case it would be: 
> 
> ruleFlowId.equals("test") == true
> 
> It's because Strings are objects, and ==  tests to see if the String is
> literally the same object as the other String, not just a String with the
> same value. != works because they aren't the same object.
> 
> Hope that works,
> Rich. 
> 
> 
> 
> --
> View this message in context: http://drools.46999.n3.nabble.com/Can-get-not-equal-to-work-but-not-equal-in-LHS-tp4022074p4022076.html
> Sent from the Drools: User forum 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