# Overload broadcasting for custom struct?

**URL:** <https://discourse.julialang.org/t/overload-broadcasting-for-custom-struct/42240>\
**Category:** General Usage\
**Created:** [June 29, 2020, 11:20am UTC](https://discourse.julialang.org/t/overload-broadcasting-for-custom-struct/42240 "2020-06-29T11:20:21Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![LaurentPlagne](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/laurentplagne/32/10103_2.png) [@LaurentPlagne](https://discourse.julialang.org/u/LaurentPlagne)\
**Post date:** [June 29, 2020, 12:07pm UTC](https://discourse.julialang.org/t/overload-broadcasting-for-custom-struct/42240/7 "2020-06-29T12:07:02Z")

</div>

Glad that is useful !  
For your second question see the discussion here

> [@Why do we need to define separate methods for commutative binary operators?](https://discourse.julialang.org/t/why-do-we-need-to-define-separate-methods-for-commutative-binary-operators/42044):
>
> Eg: julia\> struct abc x :: Int end julia\> Base.:(+)(a::abc, b::Int) = abc(a.x + b) julia\> abc(1) + 1 abc(2) julia\> 1 + abc(1) ERROR: MethodError: no method matching +(::Int64, ::abc) julia\> Base.:(==)(a::abc, b::Int) = a.x == b julia\> abc(1) == 1 true julia\> 1 == abc(1) false Shouldn’t the second method in each case automatically be defined in terms of the first? This breaks commutativity in case of the equality. A missing method would have been better than this instead of …

---

_[View the full topic](https://discourse.julialang.org/t/overload-broadcasting-for-custom-struct/42240)._
