# Arrays in Openhab 1.8.3

**URL:** <https://community.openhab.org/t/arrays-in-openhab-1-8-3/21855>\
**Category:** Scripts & Rules\
**Created:** [February 2, 2017, 12:18pm UTC](https://community.openhab.org/t/arrays-in-openhab-1-8-3/21855 "2017-02-02T12:18:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [February 4, 2017, 3:48am UTC](https://community.openhab.org/t/arrays-in-openhab-1-8-3/21855/2 "2017-02-04T03:48:02Z")

</div>

The Rules DSL doesn’t support arrays.

You can use

```
List<Number> arrayEnvironment = newArrayList

```

And then a System started rule to populate it. However, in my experience constructs like these tend to be a code angel and the usually is a better approach.

Some thoughts include:

- Store the Numbers in Items and use Group as the “array”. See:

> [@Design Pattern: Associated Items](https://community.openhab.org/t/design-pattern-associated-items/15790):
>
> Edit: Updates for OH 4 Please see [Design Pattern: What is a Design Pattern and How Do I Use Them](https://community.openhab.org/t/design-pattern-what-is-a-design-pattern-and-how-do-i-use-them/40319) for how to read and use DPs. Problem Statement Often one will have a number of separate Items which are all related to each other in some way. For example, one might have a Contact on a door and a DateTime to represent when the last time the door was opened. This is easy enough to keep track of if there are only one or two such Items, but if one has a lot of similar Items or is using a lot of gener…

> [@Design Pattern: Working with Groups in Rules](https://community.openhab.org/t/design-pattern-working-with-groups-in-rules/20512):
>
> Edit: Updates for OH 4, inclusion of JS Scripting and Blockly examples, removed the doors example as it’s superfluous. Please see [Design Pattern: What is a Design Pattern and How Do I Use Them](https://community.openhab.org/t/design-pattern-what-is-a-design-pattern-and-how-do-i-use-them/40319) for how to read and use DPs. Problem Statement One powerful way to consolidate code in rules is to use array/list manipulation operations on the members of a Group. For example, filter down to just those members that are ON, get a list of the labels of those Items that are NULL, etc. Concept T…

HashMaps often come in handy.

We are not writing code that needs to be wholly generic and shared with lots of people. Sometimes just hard coding numerical values like this in a switch statement is far simpler and just more clear than trying to do things the “right” way.

---

_[View the full topic](https://community.openhab.org/t/arrays-in-openhab-1-8-3/21855)._
