# X .-= 2 for scalar x fails

**URL:** <https://discourse.julialang.org/t/x-2-for-scalar-x-fails/16187>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 11, 2018, 3:58pm UTC](https://discourse.julialang.org/t/x-2-for-scalar-x-fails/16187 "2018-10-11T15:58:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![e3c6](https://avatars.discourse-cdn.com/v4/letter/e/e79b87/32.png) [@e3c6](https://discourse.julialang.org/u/e3c6)\
**Post date:** [October 11, 2018, 3:58pm UTC](https://discourse.julialang.org/t/x-2-for-scalar-x-fails/16187/1 "2018-10-11T15:58:57Z")

</div>

```julia
julia> x = 1
1

julia> x .-= 2
ERROR: MethodError: no method matching copyto!(::Int64, ::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0},Tuple{},typeof(-),Tuple{Int64,Int64}})

```

Is this intentional? Since scalars are iterable, why broadcast should fail here?

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [October 11, 2018, 4:21pm UTC](https://discourse.julialang.org/t/x-2-for-scalar-x-fails/16187/2 "2018-10-11T16:21:48Z")

</div>

> [@e3c6](#):
>
> Is this intentional? Since scalars are iterable, why broadcast should fail here?

Yes, this is intentional. Scalars are immutable types, not containers. Implementing the `broadcast` interface does not guarantee that this type of assignment would work. If it did, it wouldn’t be possible for scalars to implement it.

The behavior you are looking for is implemented by a 1-element array, so if you really needed this (I don’t know your use case, but I’m guessing you’d probably be better off just doing `-=`) you could create one.
