easy-rules
easy-rules copied to clipboard
How to update facts in Action:
how to update facts in yml:
`name: "weather rule" description: "if it rains then take an umbrella" condition: "rain == true" actions:
- "System.out.println("It rains, take an umbrella!");"
- "facts.put("umbrella", true); "`
[Error: unresolvable property or identifier: facts] [Near : {... facts.put("umbrella", true); ....}] ^ [Line: 1, Column: 1]
Just Same meaning as below:
``
org.jeasy.rules.api.Rule weatherRule = new RuleBuilder()
.name("weather rule")
.description("if it rains then take an umbrella")
.when(facts -> facts.get("rain").equals(true))
.then(facts -> {
System.out.println("It rains, take an umbrella!");
facts.put("umbrella", true);
})
``
See FAQ
https://github.com/j-easy/easy-rules/wiki/faqs#8-how-to-addassign-new-facts-in-rules-written-in-an-expression-language