# Tuple, Array length confusion

**URL:** <https://discourse.julialang.org/t/tuple-array-length-confusion/1185>\
**Category:** General Usage\
**Created:** [December 28, 2016, 2:20pm UTC](https://discourse.julialang.org/t/tuple-array-length-confusion/1185 "2016-12-28T14:20:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![richthanki](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@richthanki](https://discourse.julialang.org/u/richthanki)\
**Post date:** [December 28, 2016, 2:20pm UTC](https://discourse.julialang.org/t/tuple-array-length-confusion/1185/1 "2016-12-28T14:20:34Z")

</div>

A hopefully simple question. In 0.5.0 I find the following behaviour perfectly intuitive:

```julia
julia> length( [0.4,0.6,0.8] )
3

julia> length( (0.4,0.6,0.8) )
3

```

But the following feels deeply counterintuitive for tuples:

```julia
julia> length( [[0.4,0.6,0.8]] )
1

julia> length( ([0.4,0.6,0.8]) )
3

```

Could someone help as to why the tuple is ignored in the last case?

---

<div class="post-metadata">

**Author:** ![Evizero](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/evizero/32/10118_2.png) [@Evizero](https://discourse.julialang.org/u/Evizero)\
**Post date:** [December 28, 2016, 2:23pm UTC](https://discourse.julialang.org/t/tuple-array-length-confusion/1185/2 "2016-12-28T14:23:55Z")

</div>

`([0.4,0.6,0.8])` doesn’t create a tuple, just like `(1+2) ` does not create a tuple, it is just a means to explicitly state that it is important to you that whatever is in it is evaluated before interacting with the surrounding, for example `(1+2)*2` .

If you want to create a tuple, use a `,`

```nohighlight
julia> length( ([0.4,0.6,0.8],) )
1

```

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [December 28, 2016, 2:25pm UTC](https://discourse.julialang.org/t/tuple-array-length-confusion/1185/3 "2016-12-28T14:25:01Z")

</div>

> [@richthanki](#):
>
> Could someone help as to why the tuple is ignored in the last case?

It’s not a tuple at all. When creating single-element tuples, you need to use a trailing comma. Otherwise the parentheses are just used for precedence groupings. E.g., `(1)` is just `1`, but `(1,)` is a one-tuple.

`length( ([.4,.6,.8],) )`

---

<div class="post-metadata">

**Author:** ![richthanki](https://avatars.discourse-cdn.com/v4/letter/r/51bf81/32.png) [@richthanki](https://discourse.julialang.org/u/richthanki)\
**Post date:** [December 28, 2016, 2:34pm UTC](https://discourse.julialang.org/t/tuple-array-length-confusion/1185/4 "2016-12-28T14:34:18Z")

</div>

Thanks very much both. Got it 🙂
