# Array whose members are a specific type or its empty

**URL:** <https://discourse.dry-rb.org/t/array-whose-members-are-a-specific-type-or-its-empty/1369>\
**Category:** Support\
**Created:** [October 24, 2021, 1:09am UTC](https://discourse.dry-rb.org/t/array-whose-members-are-a-specific-type-or-its-empty/1369 "2021-10-24T01:09:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![edgenard](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/edgenard/32/660_2.png) [@edgenard](https://discourse.dry-rb.org/u/edgenard)\
**Post date:** [October 24, 2021, 1:09am UTC](https://discourse.dry-rb.org/t/array-whose-members-are-a-specific-type-or-its-empty/1369/1 "2021-10-24T01:09:52Z")

</div>

I’m trying to create a struct that has an attribute of an array that is either empty or each member is a specific type.

```auto
class MyStruct < Dry::Struct
  attribute :my_attribute Types::Arrray.of(Integer) | Types::Array.empty? # this doesn't work but I hope it communicates what I'm trying todo 
end

```

I’d like the array to be there and if it has anything in it, it must be a certain type, otherwise, it should be empty.

---

<div class="post-metadata">

**Author:** ![DawidJanczak](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/dawidjanczak/32/261_2.png) [@DawidJanczak](https://discourse.dry-rb.org/u/DawidJanczak)\
**Post date:** [October 25, 2021, 6:01am UTC](https://discourse.dry-rb.org/t/array-whose-members-are-a-specific-type-or-its-empty/1369/2 "2021-10-25T06:01:24Z")

</div>

Not sure I understand, what is it that `Types::Arrray.of(Integer)` lacks here? It should do exactly what you described 🙂

---

<div class="post-metadata">

**Author:** ![edgenard](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.dry-rb.org/edgenard/32/660_2.png) [@edgenard](https://discourse.dry-rb.org/u/edgenard)\
**Post date:** [October 25, 2021, 2:05pm UTC](https://discourse.dry-rb.org/t/array-whose-members-are-a-specific-type-or-its-empty/1369/3 "2021-10-25T14:05:32Z")

</div>

Thanks for the reply! I realize after playing with it that just by writing `Types::Array.of(Integer)` allows the empty array.
