# Type stability while looping over Tuple

**URL:** <https://discourse.julialang.org/t/type-stability-while-looping-over-tuple/83272>\
**Category:** Performance\
**Tags:** type-stability\
**Created:** [June 23, 2022, 7:10pm UTC](https://discourse.julialang.org/t/type-stability-while-looping-over-tuple/83272 "2022-06-23T19:10:20Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![NicolasW](https://avatars.discourse-cdn.com/v4/letter/n/c67d28/32.png) [@NicolasW](https://discourse.julialang.org/u/NicolasW)\
**Post date:** [June 24, 2022, 12:41am UTC](https://discourse.julialang.org/t/type-stability-while-looping-over-tuple/83272/7 "2022-06-24T00:41:59Z")

</div>

Discovering [this thread](https://discourse.julialang.org/t/is-there-a-way-to-forward-getindex-for-tuples-in-a-type-stable-way/2889/2) it can be resolve by recursion

```julia
function RecursiveUnroll(x::Tuple, i::Int)
	if length(x) == 0
		return nothing
	end
	# do what you want here
	RecursiveUnroll(x[2:end], i+1)
end

```

It still seems to me that this should be something the compiler could infer, as the range of the loop is static. Maybe someone could chip in here.

---

_[View the full topic](https://discourse.julialang.org/t/type-stability-while-looping-over-tuple/83272)._
