Why does indexed assignment return the assigned value instead of the container?

It is convenient for multiple assignments, for example:

julia> x = [1, 2, 3]; y = [4, 5, 6];

julia> x[2] = y[2] = 42;

julia> x
3-element Vector{Int64}:
  1
 42
  3

julia> y
3-element Vector{Int64}:
  4
 42
  6

It is convention that !-functions return the mutated container. This is also convenient for nesting, example (although not with setindex! which is rarely used directly):

julia> x = [1, 2, 3];

julia> push!(empty!(x), 42); # empty! returns x

julia> x
1-element Vector{Int64}:
 42
4 Likes