Rule MUST change the state?

12 views
Skip to first unread message

Akhil Dixit

unread,
Nov 26, 2016, 8:31:59 PM11/26/16
to runway-dev
Can I write a rule that does not change the state, but only the data inside?
When I write a rule like this, it is getting disabled on the browser interface.
Imagine a scenario in 'too many bananas' problem. If we want to include a possibility that while carrying bananas home, a person may drop few of them in the middle of the road.
Can I do this?

rule DropBananas for state in roommates {
match state {
Happy{}
Hungry{}
GoingToStore{}
ReturningFromStore(bag){
var dropped : 0..bag.carrying = urandomRange(0, bag.carrying);
state = ReturningFromStore{carrying : bag.carrying - dropped}; 
}
}

Diego Ongaro

unread,
Nov 28, 2016, 8:50:56 PM11/28/16
to runwa...@googlegroups.com
Hi Akhil,

That should be allowed, and by assigning something different back to the variable 'state', the rule does change the global state.

It's possible that you're running into this issue https://github.com/salesforce/runway-compiler/issues/2 , where if Runway happens to test the rule with a random number that doesn't alter the state (dropped=0), it then considers the rule inactive/disabled. Try replacing the random numbers with constants to see if that's the problem.

Best,
Diego

--
You received this message because you are subscribed to the Google Groups "runway-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to runway-dev+unsubscribe@googlegroups.com.
To post to this group, send email to runwa...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/runway-dev/fd35eaee-e432-4fb7-b637-873bbc668142%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages