A variable is nessecary here, because, later, I want to get the current state of every “item” and modify it.
I am aware, that i can integrate old rules, by putting them in the “rules” directory on my Rasppi, but when I do so, the “when” gets commented out.
As of now I have looked up other topics and deducted, that “var” is working for them.
I have to admitt, i’m still new to OH3 (even though I have a bit of experience with OH2) so you can think of me as a total beginner here.
This is the second case where someone has claimed that code like
TaskNum = blah blah blah
worked in OH 2.5 but doesn’t in OH 3 and adding the var to it is what fixed it. All I can say is that it never should have worked in OH 2.5 either. You have to declare all your variables using var or val before their first use.
As for your first example, again, it has always been the case, even in OH 2.5, that you cannot reference a var inside a forEach. But you can reference a val.
Finally, please don’t post screen shots of code. Paste the actual code and use code fences.
It does too, though I’ve seen some people who were apparently not using var in 2.5 with rules that supposedly worked and are now breaking. I’m skeptical that these rules actually did work (I can’t count how many times I seen “this worked in 2.5” but there is no way the code could have ever worked).
The code shown above has to be Rules DSL. You can’t just start using an Item like that without pulling it out of the item registry first (unless there is something I don’t know).
Putztruppe.members.forEach[item |
would work in Rules DSL just fine. In JavaScript though it’d have to be something like (if using Java stream API)
True enough, but I get the impression he’s getting kickback from the editor on syntax errors. The fact that Putztruppe has no value will only be seen at runtime, so the JS syntax checker wouldn’t complain.