# Size function does not work with pairs(::NamedTuple)

**URL:** <https://discourse.julialang.org/t/size-function-does-not-work-with-pairs-namedtuple/35451>\
**Category:** General Usage\
**Tags:** question, testing\
**Created:** [March 3, 2020, 10:08am UTC](https://discourse.julialang.org/t/size-function-does-not-work-with-pairs-namedtuple/35451 "2020-03-03T10:08:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ravi.joshi](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@ravi.joshi](https://discourse.julialang.org/u/ravi.joshi)\
**Post date:** [March 3, 2020, 10:08am UTC](https://discourse.julialang.org/t/size-function-does-not-work-with-pairs-namedtuple/35451/1 "2020-03-03T10:08:57Z")

</div>

The size function works as expected for pairs(::Array), but throws an error for pairs(::NamedTuple). Is it expected or a bug? Shouldn’t the functions on Pairs work uniformly for all underlying containers?  
If it is a bug, how can I open an issue?

```julia
julia> VERSION
v"1.5.0-DEV.338"

julia> A = [1, 2, 3]
3-element Array{Int64,1}:
 1
 2
 3

julia> d = pairs(A)
pairs(::Array{Int64,1}) with 3 entries:
  1 => 1
  2 => 2
  3 => 3

julia> size(d)
(3,)

julia> A = (a=1, b=2, c=3)
(a = 1, b = 2, c = 3)

julia> d = pairs(A)
pairs(::NamedTuple) with 3 entries:
  :a => 1
  :b => 2
  :c => 3

julia> size(d)
ERROR: MethodError: no method matching size(::Tuple{Symbol,Symbol,Symbol})
Closest candidates are:
  size(::Tuple, ::Integer) at tuple.jl:22
  size(::BitArray{1}) at bitarray.jl:99
  size(::BitArray{1}, ::Integer) at bitarray.jl:103
  ...
Stacktrace:
 [1] size(::Base.Iterators.Pairs{Symbol,Int64,Tuple{Symbol,Symbol,Symbol},NamedTuple{(:a, :b, :c),Tuple{Int64,Int64,Int64}}}) at ./iterators.jl:232
 [2] top-level scope at REPL[154]:1

```

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 3, 2020, 10:11am UTC](https://discourse.julialang.org/t/size-function-does-not-work-with-pairs-namedtuple/35451/2 "2020-03-03T10:11:18Z")

</div>

`pairs` is an iterator and its support for `size` is accidental. Use `length`.

See [Interfaces · The Julia Language](https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-iteration-1)
