# How to tell Julia that my type is not iterable?

**URL:** https://discourse.julialang.org/t/how-to-tell-julia-that-my-type-is-not-iterable/112767
**Category:** General Usage
**Tags:** development
**Created:** [April 10, 2024, 12:27pm UTC](https://discourse.julialang.org/t/how-to-tell-julia-that-my-type-is-not-iterable/112767 "2024-04-10T12:27:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)
#### Post date: [April 10, 2024, 12:27pm UTC](https://discourse.julialang.org/t/how-to-tell-julia-that-my-type-is-not-iterable/112767/1 "2024-04-10T12:27:39Z")

</div>

How do I tell Julia that my object is not iterable? How do I make `a, b, c = some_function.(mytype, (1, 2, 3))` work automatically without throwing `no method matching length(::MyType)`?

---

<div class="post-metadata">

### Author: ![adienes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adienes/32/37459_2.png) [@adienes](https://discourse.julialang.org/u/adienes)
#### Post date: [April 10, 2024, 12:40pm UTC](https://discourse.julialang.org/t/how-to-tell-julia-that-my-type-is-not-iterable/112767/2 "2024-04-10T12:40:25Z")

</div>

the easy way:

wrap it in something iterable

```julia
some_function.(Ref(mytype), (1, 2, 3))

```

if you want this to work in general without wrapping would be to change the `BroadcastStyle` of your object

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [April 10, 2024, 12:40pm UTC](https://discourse.julialang.org/t/how-to-tell-julia-that-my-type-is-not-iterable/112767/3 "2024-04-10T12:40:49Z")

</div>

You want `Base.broadcastable(x::T) = Ref(x)`. See [here](https://docs.julialang.org/en/v1/manual/interfaces/#man-interfaces-broadcasting)

```julia
julia> struct A end

julia> foo(a::A, x) = x;

julia> foo.(A(), [1, 2])
ERROR: MethodError: no method matching length(::A)

julia> Base.broadcastable(a::A) = Ref(a);

julia> foo.(A(), [1, 2])
2-element Vector{Int64}:
 1
 2

```
