# Cleaner if statements

**URL:** <https://discuss.elastic.co/t/cleaner-if-statements/163796>\
**Category:** Logstash\
**Created:** [January 10, 2019, 6:02pm UTC](https://discuss.elastic.co/t/cleaner-if-statements/163796 "2019-01-10T18:02:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fozboz](https://avatars.discourse-cdn.com/v4/letter/f/df788c/32.png) [@fozboz](https://discuss.elastic.co/u/fozboz)\
**Post date:** [January 10, 2019, 6:02pm UTC](https://discuss.elastic.co/t/cleaner-if-statements/163796/1 "2019-01-10T18:02:58Z")

</div>

Is there a tidier way to write this?

```auto
if [content][eventType] == 11 or [content][eventType] == 13 or [content][eventType] == 20 or [content][eventType] == 21 or [content][eventType] == 23 or [content][eventType] == 26 {
  do some stuff
}

```

E.g. can we do something like this?

```auto
arrayOfPossibleThings = [11,13,20,21,23,26]
if [content][eventType] in arrayOfPossibleThings {
  do some stuff
}

```

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [January 10, 2019, 6:54pm UTC](https://discuss.elastic.co/t/cleaner-if-statements/163796/2 "2019-01-10T18:54:28Z")

</div>

> [@fozboz](#):
>
> can we do something like this?

You can do

```
if [content][eventType] in [11,13,20,21,23,26] {

```

---

<div class="post-metadata">

**Author:** ![fozboz](https://avatars.discourse-cdn.com/v4/letter/f/df788c/32.png) [@fozboz](https://discuss.elastic.co/u/fozboz)\
**Post date:** [January 28, 2019, 11:34pm UTC](https://discuss.elastic.co/t/cleaner-if-statements/163796/3 "2019-01-28T23:34:44Z")

</div>

Perfect, thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 25, 2019, 11:34pm UTC](https://discuss.elastic.co/t/cleaner-if-statements/163796/4 "2019-02-25T23:34:48Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
