# Help implementing new iterate interface?

**URL:** <https://discourse.julialang.org/t/help-implementing-new-iterate-interface/14669>\
**Category:** Internals & Design\
**Created:** [September 7, 2018, 3:44pm UTC](https://discourse.julialang.org/t/help-implementing-new-iterate-interface/14669 "2018-09-07T15:44:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![crbinz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/crbinz/32/1919_2.png) [@crbinz](https://discourse.julialang.org/u/crbinz)\
**Post date:** [September 7, 2018, 3:44pm UTC](https://discourse.julialang.org/t/help-implementing-new-iterate-interface/14669/1 "2018-09-07T15:44:32Z")

</div>

I’m trying to implement the new `iterate` interface in [`JLD.jl`](https://github.com/JuliaIO/JLD.jl/blob/master/src/JLD.jl#L330), but I can’t get it to work, mostly because I don’t quite understand the original implementation.

I tried

```julia
Base.iterate(parent::Union{JldFile, JldGroup}, state) = state[2] < length(state[1]) ? nothing : 
        (parent[state[1][state[2]]], (state[1], state[2]+1))

```

but that did not work.

---

<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:** [September 7, 2018, 3:51pm UTC](https://discourse.julialang.org/t/help-implementing-new-iterate-interface/14669/2 "2018-09-07T15:51:13Z")

</div>

did you try giving `state` the default value that `start` used to return? i.e.

```julia
Base.iterate(parent::Union{JldFile, JldGroup}, state = (names(parent), 1)) = ...

```

---

<div class="post-metadata">

**Author:** ![crbinz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/crbinz/32/1919_2.png) [@crbinz](https://discourse.julialang.org/u/crbinz)\
**Post date:** [September 7, 2018, 4:07pm UTC](https://discourse.julialang.org/t/help-implementing-new-iterate-interface/14669/3 "2018-09-07T16:07:28Z")

</div>

Perfect, that seems to have worked. Thanks!
