-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Otherwise" evaluated to early in switch node #4659
Comments
Order matters and otherwise is expected to be last |
Yes, this is the actual behavior and from a programmers perspective that is reasonable. After I found out that makes sense to me as well but this seems to be unintuitive for some non technical users. |
I don't think there is anything to fix here is there ? |
While this may be obvious to technical people, is it worth adding a note to the switch node to say rules are processed in order from top to bottom? |
This might be a bit of a "stupid" message. This behavior is directly related to programming and not to Node-RED, I rather suggest a light learning in the [1] the window with the new features of the current version. |
I'd just add one thing: the switch node defaults to "checking all rules" which, to my non-programming mind, certainly seems to say the order of the rules makes no difference. I note this because I, too, have sometimes put "otherwise" first only to discover my flow didn't work properly since I assumed the node was going to check all rules since... that's what it said it would do. If "otherwise" is always last from a programmer's POV, perhaps it could automatically be placed last when selected by the user or at least clarify what "checking all rules" means since that implies order is irrelevant. Or name it "otherwise (must come last)" or somesuch so the end user knows. |
Being a programmer before ever touching Node-RED, I can say I have never put the However, I can certainly see why a non programmer might reasonable expect I am not actually advocating that we should reprogram the switch node to support this but rather we might consider adding some kind of visual feedback like a form-tip that is only shown when |
Current Behavior
Due to flow layout reasons I changed the order of the cases in the switch node to
I recognized that the message is forwarded to both outputs which causes unexpected behavior.
Expected Behavior
The order of the cases should be honored. Nevertheless I expect the "otherwise" to be evaluated at last wherever it is located in the conditions of the switch node.
Steps To Reproduce
You will see that the message "10" is printed for both outputs.
Example flow
Environment
I am running the official Node-Red docker image on a linux host.
The text was updated successfully, but these errors were encountered: