Joshua Undesser wrote:
I have a question on the return value of a not statement........
'not' has no return value, and you can't bind to it - after all it
is
the absence of something, how can you bind to nothing.
I have two fairly large rules in respect to the LHS when
declarations.
They are identical except for the fact that in one of them, I am checking to
see if one more object exits, while in the other I am checking to see if it
doesn't exist. It seems silly to try have duplicate rules expressively
typed when this is the only difference. So what i tried to do was bind the
value of the not statement as shown below....
rule "Rule Name"
no-loop = true
when
.........
$msg : (or Message (description == "OK")
not Message (description == "OK"))
.........
then
if ($msg == null) {
createMessage("OK"); //
}
.... rest of RHS.....
end
I figured if the Message object didn't exist, null would be returned and
assigned to the $msg variable. But it was not. For now I have it
separated into two rules, but logically I would like to combine them, as
every other part of the LHS and RHS match.
nope, doesn't work that way, you can't bind to a not.
I also tried a few different variants as shown below thinking it
would work,
but didn't.
rule "Rule Name"
no-loop = true
when
.........
(or $msg : Message (description == "OK")
not Message (description == "OK"))
.........
then
if ($msg == null) {
createMessage("OK"); //
}
.... rest of RHS.....
end
I even tried the above with the entire "then" side encapsulated in a
try/catch block to catch the null pointer that gets thrown, but no luck.
Anyone have any suggestions? Just seems like there should be a way to do
this.
nope.