# Documentation of the iteration interface is confusing

**URL:** <https://discourse.julialang.org/t/documentation-of-the-iteration-interface-is-confusing/11141>\
**Category:** New to Julia\
**Created:** [May 25, 2018, 11:20am UTC](https://discourse.julialang.org/t/documentation-of-the-iteration-interface-is-confusing/11141 "2018-05-25T11:20:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![leiteiro](https://avatars.discourse-cdn.com/v4/letter/l/b5e925/32.png) [@leiteiro](https://discourse.julialang.org/u/leiteiro)\
**Post date:** [May 25, 2018, 11:20am UTC](https://discourse.julialang.org/t/documentation-of-the-iteration-interface-is-confusing/11141/1 "2018-05-25T11:20:11Z")

</div>

The [docs](https://docs.julialang.org/en/latest/manual/interfaces.html) list _two_ methods as _required_: iterate(iter) and iterate(iter, state).

Later, in the first example, only one function is defined.  
At least for a beginner, that’s confusing.

---

<div class="post-metadata">

**Author:** ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)\
**Post date:** [May 25, 2018, 11:29am UTC](https://discourse.julialang.org/t/documentation-of-the-iteration-interface-is-confusing/11141/2 "2018-05-25T11:29:40Z")

</div>

Note that

```julia
Base.iterate(S::Squares, state=1) = state > S.count ? nothing : (state*state, state+1)

```

defines two methods.

`Base.iterate(S::Squares)` and `Base.iterate(S::Squares, state)`

But it might be worth being more explicit.

---

<div class="post-metadata">

**Author:** ![ScottPJones](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/scottpjones/32/146_2.png) [@ScottPJones](https://discourse.julialang.org/u/ScottPJones)\
**Post date:** [May 25, 2018, 12:30pm UTC](https://discourse.julialang.org/t/documentation-of-the-iteration-interface-is-confusing/11141/3 "2018-05-25T12:30:00Z")

</div>

> [@leiteiro](#):
>
> Later, in the first example, only one function is defined.  
> At least for a beginner, that’s confusing.

Yep, the distinction between functions and methods in Julia can be confusing for beginners, esp. in cases such as this one where some methods are created implicitly.  
Also confusing the issue might be that the distinction is different than the one made in OO languages  
(i.e. methods belonging to classes).
