# How can you dispatch on Iterator eltype including generators?

**URL:** <https://discourse.julialang.org/t/how-can-you-dispatch-on-iterator-eltype-including-generators/20511>\
**Category:** General Usage\
**Created:** [February 6, 2019, 5:46pm UTC](https://discourse.julialang.org/t/how-can-you-dispatch-on-iterator-eltype-including-generators/20511 "2019-02-06T17:46:53Z")\
**Posts on this page:** 1\
**Showing post:** 7

<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:** [February 7, 2019, 8:15am UTC](https://discourse.julialang.org/t/how-can-you-dispatch-on-iterator-eltype-including-generators/20511/7 "2019-02-07T08:15:23Z")

</div>

If you need to precompute something once, but hide that from the interface, you may find

> [@Best practice approach for caching data in objects](https://discourse.julialang.org/t/best-practice-approach-for-caching-data-in-objects/20419):
>
> Something that’s come up repeatedly for me this last week in different contexts (and also many times before) is how do you approach the case where you sometimes want to be able to store intermediary results? For a clearly contrived MWE, let’s say we have a type wrapping an Array and in certain contexts we often evaluate the extrema. Let’s say we don’t have to worry about cache invalidation (e.g. either 1) the values of the array don’t change or 2) we can only change the value using a setter fun…

useful.

---

_[View the full topic](https://discourse.julialang.org/t/how-can-you-dispatch-on-iterator-eltype-including-generators/20511)._
