# How to pattern match an array with unknown length

**URL:** <https://community.haxe.org/t/how-to-pattern-match-an-array-with-unknown-length/1367>\
**Category:** Haxe\
**Created:** [December 13, 2018, 2:41am UTC](https://community.haxe.org/t/how-to-pattern-match-an-array-with-unknown-length/1367 "2018-12-13T02:41:38Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![skylerparr](https://community.haxe.org/user_avatar/community.haxe.org/skylerparr/32/502_2.png) [@skylerparr](https://community.haxe.org/u/skylerparr)\
**Post date:** [December 13, 2018, 2:41am UTC](https://community.haxe.org/t/how-to-pattern-match-an-array-with-unknown-length/1367/1 "2018-12-13T02:41:38Z")

</div>

I’ve been digging into pattern matching more in Haxe. I don’t see anything in the docs or cookbook about matching on arrays with unknown length. Here’s a code example of what I’m trying to achieve:

```haxe
function getSpecialTail(array: Array<Int>): Array<Int> {
   return switch(array) {
      case [4, 8, 12, tail ...]:
           tail;
       case _:
           []; 
   }
}

```

`trace(getSpecialTail([4, 8, 12, 5, 8, 7]));`  
`>>` [5, 8, 7]

I’m using the ellipsis to signify some operator to let the compiler know to match on any number of elements left in the array. Is there a way to do that?

Thanks.

---

_[View the full topic](https://community.haxe.org/t/how-to-pattern-match-an-array-with-unknown-length/1367)._
