# Using hcat with splatting on arrays of different lengths kills Julia

**URL:** <https://discourse.julialang.org/t/using-hcat-with-splatting-on-arrays-of-different-lengths-kills-julia/15733>\
**Category:** General Usage\
**Tags:** compilation, memory, memory-allocation\
**Created:** [October 1, 2018, 12:44pm UTC](https://discourse.julialang.org/t/using-hcat-with-splatting-on-arrays-of-different-lengths-kills-julia/15733 "2018-10-01T12:44:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [October 1, 2018, 8:11pm UTC](https://discourse.julialang.org/t/using-hcat-with-splatting-on-arrays-of-different-lengths-kills-julia/15733/2 "2018-10-01T20:11:22Z")

</div>

Use `reduce(hcat, X)` instead, which calls an efficient specialized method. In general one should avoid splatting collections whose number of elements can vary a lot, since as you noted it triggers a lot of compilation.

---

_[View the full topic](https://discourse.julialang.org/t/using-hcat-with-splatting-on-arrays-of-different-lengths-kills-julia/15733)._
