# Anyone know how to do broadcasting on a function with a non-iterable argument? i.e

**URL:** <https://discourse.julialang.org/t/anyone-know-how-to-do-broadcasting-on-a-function-with-a-non-iterable-argument-i-e/55051>\
**Category:** General Usage\
**Created:** [February 11, 2021, 9:47am UTC](https://discourse.julialang.org/t/anyone-know-how-to-do-broadcasting-on-a-function-with-a-non-iterable-argument-i-e/55051 "2021-02-11T09:47:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BridgeBot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bridgebot/32/21491_2.png) [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)\
**Post date:** [February 11, 2021, 9:47am UTC](https://discourse.julialang.org/t/anyone-know-how-to-do-broadcasting-on-a-function-with-a-non-iterable-argument-i-e/55051/1 "2021-02-11T09:47:00Z")

</div>

anyone know how to do broadcasting on a function with a non-iterable argument? i.e. `f(x,p) = x*p.val` where `p` is a struct with a single value `val` . Thus, the desired result would be broadcasting over x and multiplying every value by `val`. Is there a way to do this without making the struct type of `p` behave like an array?

Note that the original poster on Slack cannot see your response here on Discourse. Consider _transcribing the appropriate answer back to Slack_, or pinging the poster here on Discourse so they can _follow this thread_.  
[(Original message :slack:)](https://julialang.slack.com/archives/C6A044SQH/p1613036775038100?thread_ts=1613036775.038100&cid=C6A044SQH) [(More Info)](https://github.com/JuliaCommunity/SlackBridge)

---

<div class="post-metadata">

**Author:** ![bgroenks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bgroenks/32/21784_2.png) [@bgroenks](https://discourse.julialang.org/u/bgroenks)\
**Post date:** [February 11, 2021, 9:49am UTC](https://discourse.julialang.org/t/anyone-know-how-to-do-broadcasting-on-a-function-with-a-non-iterable-argument-i-e/55051/2 "2021-02-11T09:49:19Z")

</div>

Whoops totally missed this post…

> [@Broadcasting structs as scalars](https://discourse.julialang.org/t/broadcasting-structs-as-scalars/14310):
>
> The following code used to work in Julia v0.6.4, but it is not working in Julia v1.0. struct Q x::Int end f(q::Q, x::Int) = q.x + x f.(Q(2), [1,2,3]) # ERROR: MethodError: no method matching length(::Q) What should I do to broadcast on Q as a scalar?

That’s the solution!
