This is a Ruby tree! It shows every object from the Ruby Programming Language in a tree format.
# Array.[]= (from ruby core) --- array[index] = object -> object array[start, length] = object -> object array[range] = object -> object --- Assigns elements in `self`; returns the given `object`. When Integer argument `index` is given, assigns `object` to an element in `self`. If `index` is non-negative, assigns `object` the element at offset `index`: a = [:foo, 'bar', 2] a[0] = 'foo' # => "foo" a # => ["foo", "bar", 2] If `index` is greater than `self.length`, extends the array: a = [:foo, 'bar', 2] a[7] = 'foo' # => "foo" a # => [:foo, "bar", 2, nil, nil, nil, nil, "foo"] If `index` is negative, counts backwards from the end of the array: a = [:foo, 'bar', 2] a[-1] = 'two' # => "two" a # => [:foo, "bar", "two"] When Integer arguments `start` and `length` are given and `object` is not an Array, removes `length - 1` elements beginning at offset `start`, and assigns `object` at offset `start`: a = [:foo, 'bar', 2] a[0, 2] = 'foo' # => "foo" a # => ["foo", 2] If `start` is negative, counts backwards from the end of the array: a = [:foo, 'bar', 2] a[-2, 2] = 'foo' # => "foo" a # => [:foo, "foo"] If `start` is non-negative and outside the array (` >= self.size`), extends the array with `nil`, assigns `object` at offset `start`, and ignores `length`: a = [:foo, 'bar', 2] a[6, 50] = 'foo' # => "foo" a # => [:foo, "bar", 2, nil, nil, nil, "foo"] If `length` is zero, shifts elements at and following offset `start` and assigns `object` at offset `start`: a = [:foo, 'bar', 2] a[1, 0] = 'foo' # => "foo" a # => [:foo, "foo", "bar", 2] If `length` is too large for the existing array, does not extend the array: a = [:foo, 'bar', 2] a[1, 5] = 'foo' # => "foo" a # => [:foo, "foo"] When Range argument `range` is given and `object` is an Array, removes `length - 1` elements beginning at offset `start`, and assigns `object` at offset `start`: a = [:foo, 'bar', 2] a[0..1] = 'foo' # => "foo" a # => ["foo", 2] if `range.begin` is negative, counts backwards from the end of the array: a = [:foo, 'bar', 2] a[-2..2] = 'foo' # => "foo" a # => [:foo, "foo"] If the array length is less than `range.begin`, assigns `object` at offset `range.begin`, and ignores `length`: a = [:foo, 'bar', 2] a[6..50] = 'foo' # => "foo" a # => [:foo, "bar", 2, nil, nil, nil, "foo"] If `range.end` is zero, shifts elements at and following offset `start` and assigns `object` at offset `start`: a = [:foo, 'bar', 2] a[1..0] = 'foo' # => "foo" a # => [:foo, "foo", "bar", 2] If `range.end` is negative, assigns `object` at offset `start`, retains `range.end.abs -1` elements past that, and removes those beyond: a = [:foo, 'bar', 2] a[1..-1] = 'foo' # => "foo" a # => [:foo, "foo"] a = [:foo, 'bar', 2] a[1..-2] = 'foo' # => "foo" a # => [:foo, "foo", 2] a = [:foo, 'bar', 2] a[1..-3] = 'foo' # => "foo" a # => [:foo, "foo", "bar", 2] a = [:foo, 'bar', 2] If `range.end` is too large for the existing array, replaces array elements, but does not extend the array with `nil` values: a = [:foo, 'bar', 2] a[1..5] = 'foo' # => "foo" a # => [:foo, "foo"]
This is MURDOC! A Ruby documentation browser inspired by Smalltalk-80. It allows you to learn about Ruby by browsing through its class hierarchies, and see any of its methods.