For Array a
, I'm doing a[range] = obj
. Here's what I think I see:
If range.end
is negative, assigns obj
at offset start
, retains range.end.abs-1
elements past that, and removes those beyond:
a = [:foo, 'bar', baz = 2]
a[1..-1] = 'foo' # => "foo"
a # => [:foo, "foo"]
a = [:foo, 'bar', baz = 2]
a[1..-2] = 'foo' # => "foo"
a # => [:foo, "foo", 2]
a = [:foo, 'bar', baz = 2]
a[1..-3] = 'foo' # => "foo"
a # => [:foo, "foo", "bar", 2]
a = [:foo, 'bar', baz = 2]
a[1..-4] = 'foo' # => "foo"
a # => [:foo, "foo", "bar", 2]