You could certainly improve your contextual communication, however I'm guessing you're pointing out that brackets are treated as slices when on the left hand side of assignment? This is true, and good, and really the only behavior that makes any sense. But you are right that it isn't currently consistent.
On Mon, Mar 7, 2016 at 9:49 PM, Daniel Carrera <[email protected]> wrote: > That is not literally true: > > vals[2:3] = vals[3:4] > > > On Tuesday, 8 March 2016 02:37:26 UTC+1, John Myles White wrote: >> >> Array indexing produces a brand new array that has literally no >> relationship with the source array. >> >> -- John >> >> On Monday, March 7, 2016 at 5:21:34 PM UTC-8, Daniel Carrera wrote: >>> >>> Hello, >>> >>> Some Julia functions act on their inputs. For example: >>> >>> julia> vals = [6,5,4,3] >>> 4-element Array{Int64,1}: >>> 6 >>> 5 >>> 4 >>> 3 >>> >>> julia> sort!(vals); >>> >>> julia> vals >>> 4-element Array{Int64,1}: >>> 3 >>> 4 >>> 5 >>> 6 >>> >>> >>> However, it looks like these functions do not modify array slices: >>> >>> julia> vals = [6,5,4,3] >>> 4-element Array{Int64,1}: >>> 6 >>> 5 >>> 4 >>> 3 >>> >>> julia> sort!(vals[2:end]) >>> 3-element Array{Int64,1}: >>> 3 >>> 4 >>> 5 >>> >>> julia> vals >>> 4-element Array{Int64,1}: >>> 6 >>> 5 >>> 4 >>> 3 >>> >>> >>> Can anyone explain to me why this happens? Is this a language feature? >>> Is it at all possible to make a destructive function that acts on slices? >>> >>> Cheers, >>> Daniel. >>> >>>
