# How to assignment of single value to multiple indexes to an Array?

**URL:** https://discourse.julialang.org/t/how-to-assignment-of-single-value-to-multiple-indexes-to-an-array/14263
**Category:** General Usage
**Tags:** question
**Created:** [August 29, 2018, 7:54pm UTC](https://discourse.julialang.org/t/how-to-assignment-of-single-value-to-multiple-indexes-to-an-array/14263 "2018-08-29T19:54:35Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![jwu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jwu/32/3775_2.png) [@jwu](https://discourse.julialang.org/u/jwu)
#### Post date: [August 29, 2018, 7:54pm UTC](https://discourse.julialang.org/t/how-to-assignment-of-single-value-to-multiple-indexes-to-an-array/14263/1 "2018-08-29T19:54:35Z")

</div>

This code works in Julia 0.6, but not the latest Julia 0.7. Is there any alternative ways to do this?

```julia
seg = zeros(UInt32,(100,100,100))       
seg[48:52,48:52, 1:end] = one(UInt32)  

```

I got errors as follows:

```julia
ERROR: MethodError: no method matching setindex_shape_check(::UInt32, ::Int64, ::Int64, ::Int64)      
Closest candidates are:                                                                               
  setindex_shape_check(::AbstractArray, ::Integer...) at indices.jl:154                               
  setindex_shape_check(::AbstractArray{#s57,1} where #s57, ::Integer, ::Integer) at indices.jl:196    
  setindex_shape_check(::AbstractArray{#s57,2} where #s57, ::Integer, ::Integer) at indices.jl:200    
  ...                                                                                                 
Stacktrace:                                                                                           
 [1] macro expansion at ./multidimensional.jl:641 [inlined]                                           
 [2] _unsafe_setindex!(::IndexLinear, ::Array{UInt32,3}, ::UInt32, ::UnitRange{Int64}, ::UnitRange{Int
64}, ::UnitRange{Int64}) at ./multidimensional.jl:636                                                 
 [3] _setindex! at ./multidimensional.jl:631 [inlined]                                                
 [4] setindex!(::Array{UInt32,3}, ::UInt32, ::UnitRange{Int64}, ::UnitRange{Int64}, ::UnitRange{Int64}
) at ./abstractarray.jl:998                                                                           
 [5] top-level scope at none:0                                                                        

```

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [August 29, 2018, 7:56pm UTC](https://discourse.julialang.org/t/how-to-assignment-of-single-value-to-multiple-indexes-to-an-array/14263/2 "2018-08-29T19:56:28Z")

</div>

Julia 0.7 should give you a deprecation message with the replacement:

```julia
julia> seg[48:52,48:52, 1:end] = one(UInt32)
┌ Warning: using `A[I...] = x` to implicitly broadcast `x` across many locations is deprecated. Use `A[I...] .= x` instead.
│ caller = top-level scope at none:0
└ @ Core none:0

```

---

<div class="post-metadata">

### Author: ![jwu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jwu/32/3775_2.png) [@jwu](https://discourse.julialang.org/u/jwu)
#### Post date: [August 29, 2018, 8:01pm UTC](https://discourse.julialang.org/t/how-to-assignment-of-single-value-to-multiple-indexes-to-an-array/14263/3 "2018-08-29T20:01:56Z")

</div>

thanks for the quick reply. It turns out that I was using Julia 1.0 rather than 0.7!

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [August 29, 2018, 8:25pm UTC](https://discourse.julialang.org/t/how-to-assignment-of-single-value-to-multiple-indexes-to-an-array/14263/4 "2018-08-29T20:25:09Z")

</div>

Just a friendly reminder for other people who come across issues like this in the future: [PSA: use Julia 0.7 if you are upgrading](https://discourse.julialang.org/t/psa-use-julia-0-7-if-you-are-upgrading/13321)
