151151#
152152# ## Example Usage
153153#
154- # In addition to the methods it mixes in through the Enumerable module, the
155- # ` Array` class has proprietary methods for accessing, searching and otherwise
154+ # In addition to the methods it mixes in through the Enumerable module, class
155+ # Array has proprietary methods for accessing, searching and otherwise
156156# manipulating arrays.
157157#
158158# Some of the more common ones are illustrated below.
200200#
201201# arr.drop(3) #=> [4, 5, 6]
202202#
203- # ## Obtaining Information about an ` Array`
203+ # ## Obtaining Information about an Array
204204#
205- # Arrays keep track of their own length at all times. To query an array about
205+ # An array keeps track of its own length at all times. To query an array about
206206# the number of elements it contains, use #length, #count or #size.
207207#
208208# browsers = ['Chrome', 'Firefox', 'Safari', 'Opera', 'IE']
217217#
218218# browsers.include?('Konqueror') #=> false
219219#
220- # ## Adding Items to Arrays
220+ # ## Adding Items to an Array
221221#
222222# Items can be added to the end of an array by using either #push or #<<
223223#
238238# arr.insert(3, 'orange', 'pear', 'grapefruit')
239239# #=> [0, 1, 2, "orange", "pear", "grapefruit", "apple", 3, 4, 5, 6]
240240#
241- # ## Removing Items from an ` Array`
241+ # ## Removing Items from an Array
242242#
243243# The method #pop removes the last element in an array and returns it:
244244#
277277# arr = [2, 5, 6, 556, 6, 6, 8, 9, 0, 123, 556]
278278# arr.uniq #=> [2, 5, 6, 556, 8, 9, 0, 123]
279279#
280- # ## Iterating over Arrays
280+ # ## Iterating over an Array
281281#
282- # Like all classes that include the Enumerable module, ` Array` has an each
282+ # Like all classes that include the Enumerable module, class Array has an each
283283# method, which defines what elements should be iterated over and how. In case
284- # of Array's #each, all elements in the `Array` instance are yielded to the
285- # supplied block in sequence.
284+ # of Array#each, all elements in `self` are yielded to the supplied block in
285+ # sequence.
286286#
287287# Note that this operation leaves the array unchanged.
288288#
307307# arr.map! {|a| a**2} #=> [1, 4, 9, 16, 25]
308308# arr #=> [1, 4, 9, 16, 25]
309309#
310- # ## Selecting Items from an ` Array`
310+ # ## Selecting Items from an Array
311311#
312312# Elements can be selected from an array according to criteria defined in a
313313# block. The selection can happen in a destructive or a non-destructive manner.
340340#
341341# ## What's Here
342342#
343- # First, what's elsewhere. Class ` Array` :
343+ # First, what's elsewhere. Class Array:
344344#
345345# * Inherits from [class Object](rdoc-ref:Object@What-27s+Here).
346346# * Includes [module Enumerable](rdoc-ref:Enumerable@What-27s+Here), which
347347# provides dozens of additional methods.
348348#
349- # Here, class ` Array` provides methods that are useful for:
349+ # Here, class Array provides methods that are useful for:
350350#
351351# * [Creating an Array](rdoc-ref:Array@Methods+for+Creating+an+Array)
352352# * [Querying](rdoc-ref:Array@Methods+for+Querying)
359359# * [Converting](rdoc-ref:Array@Methods+for+Converting)
360360# * [And more....](rdoc-ref:Array@Other+Methods)
361361#
362- # ### Methods for Creating an ` Array`
362+ # ### Methods for Creating an Array
363363#
364364# * ::[]: Returns a new array populated with given objects.
365365# * ::new: Returns a new array.
524524# return-value.
525525# * #flatten: Returns an array that is a recursive flattening of `self`.
526526# * #inspect (aliased as #to_s): Returns a new String containing the elements.
527- # * #join: Returns a newsString containing the elements joined by the field
527+ # * #join: Returns a new String containing the elements joined by the field
528528# separator.
529529# * #to_a: Returns `self` or a new array containing all elements.
530530# * #to_ary: Returns `self`.
@@ -840,9 +840,8 @@ class Array[unchecked out Elem] < Object
840840 #
841841 # If `index` is out of range, returns `nil`.
842842 #
843- # When two Integer arguments `start` and `length` are given, returns a new
844- # `Array` of size `length` containing successive elements beginning at offset
845- # `start`:
843+ # When two Integer arguments `start` and `length` are given, returns a new array
844+ # of size `length` containing successive elements beginning at offset `start`:
846845 #
847846 # a = [:foo, 'bar', 2]
848847 # a[0, 2] # => [:foo, "bar"]
@@ -856,7 +855,7 @@ class Array[unchecked out Elem] < Object
856855 # a[1, 3] # => ["bar", 2]
857856 # a[2, 2] # => [2]
858857 #
859- # If `start == self.size` and `length >= 0`, returns a new empty `Array` .
858+ # If `start == self.size` and `length >= 0`, returns a new empty array .
860859 #
861860 # If `length` is negative, returns `nil`.
862861 #
@@ -867,7 +866,7 @@ class Array[unchecked out Elem] < Object
867866 # a[0..1] # => [:foo, "bar"]
868867 # a[1..2] # => ["bar", 2]
869868 #
870- # Special case: If `range.start == a.size`, returns a new empty `Array` .
869+ # Special case: If `range.start == a.size`, returns a new empty array .
871870 #
872871 # If `range.end` is negative, calculates the end index from the end:
873872 #
@@ -891,7 +890,7 @@ class Array[unchecked out Elem] < Object
891890 # a[4..-1] # => nil
892891 #
893892 # When a single Enumerator::ArithmeticSequence argument `aseq` is given, returns
894- # an `Array` of elements corresponding to the indexes produced by the sequence.
893+ # an array of elements corresponding to the indexes produced by the sequence.
895894 #
896895 # a = ['--', 'data1', '--', 'data2', '--', 'data3']
897896 # a[(1..).step(2)] # => ["data1", "data2", "data3"]
@@ -976,8 +975,8 @@ class Array[unchecked out Elem] < Object
976975 # a # => [:foo, "bar", "two"]
977976 #
978977 # When Integer arguments `start` and `length` are given and `object` is not an
979- # `Array` , removes `length - 1` elements beginning at offset `start`, and
980- # assigns `object` at offset `start`:
978+ # array , removes `length - 1` elements beginning at offset `start`, and assigns
979+ # `object` at offset `start`:
981980 #
982981 # a = [:foo, 'bar', 2]
983982 # a[0, 2] = 'foo' # => "foo"
@@ -1010,7 +1009,7 @@ class Array[unchecked out Elem] < Object
10101009 # a[1, 5] = 'foo' # => "foo"
10111010 # a # => [:foo, "foo"]
10121011 #
1013- # When Range argument `range` is given and `object` is not an `Array` , removes
1012+ # When Range argument `range` is given and `object` is not an array , removes
10141013 # `length - 1` elements beginning at offset `start`, and assigns `object` at
10151014 # offset `start`:
10161015 #
@@ -1274,9 +1273,9 @@ class Array[unchecked out Elem] < Object
12741273
12751274 # <!--
12761275 # rdoc-file=array.c
1277- # - collect! {|element| ... } -> new_array
1276+ # - collect! {|element| ... } -> self
12781277 # - collect! -> new_enumerator
1279- # - map! {|element| ... } -> new_array
1278+ # - map! {|element| ... } -> self
12801279 # - map! -> new_enumerator
12811280 # -->
12821281 # With a block given, calls the block with each element of `self` and replaces
@@ -1564,7 +1563,7 @@ class Array[unchecked out Elem] < Object
15641563
15651564 # <!--
15661565 # rdoc-file=array.c
1567- # - array. dig(index, *identifiers) -> object
1566+ # - dig(index, *identifiers) -> object
15681567 # -->
15691568 # Finds and returns the object in nested object specified by `index` and
15701569 # `identifiers`; the nested objects may be instances of various classes. See
@@ -1693,7 +1692,7 @@ class Array[unchecked out Elem] < Object
16931692
16941693 # <!--
16951694 # rdoc-file=array.c
1696- # - array. empty? -> true or false
1695+ # - empty? -> true or false
16971696 # -->
16981697 # Returns `true` if the count of elements in `self` is zero, `false` otherwise.
16991698 #
@@ -1804,10 +1803,10 @@ class Array[unchecked out Elem] < Object
18041803
18051804 # <!--
18061805 # rdoc-file=array.c
1807- # - fill(object, start = nil, count = nil) -> new_array
1808- # - fill(object, range) -> new_array
1809- # - fill(start = nil, count = nil) {|element| ... } -> new_array
1810- # - fill(range) {|element| ... } -> new_array
1806+ # - fill(object, start = nil, count = nil) -> self
1807+ # - fill(object, range) -> self
1808+ # - fill(start = nil, count = nil) {|element| ... } -> self
1809+ # - fill(range) {|element| ... } -> self
18111810 # -->
18121811 # Replaces selected elements in `self`; may add elements to `self`; always
18131812 # returns `self` (never a new array).
@@ -2300,7 +2299,7 @@ class Array[unchecked out Elem] < Object
23002299
23012300 # <!--
23022301 # rdoc-file=array.c
2303- # - array. join(separator = $,) -> new_string
2302+ # - join(separator = $,) -> new_string
23042303 # -->
23052304 # Returns the new string formed by joining the converted elements of `self`; for
23062305 # each element `element`:
@@ -3115,7 +3114,7 @@ class Array[unchecked out Elem] < Object
31153114 #
31163115 # The order of the result array is unrelated to the order of `self`.
31173116 #
3118- # Returns a new empty `Array` if `self` is empty:
3117+ # Returns a new empty array if `self` is empty:
31193118 #
31203119 # [].sample(4) # => []
31213120 #
@@ -3320,9 +3319,8 @@ class Array[unchecked out Elem] < Object
33203319 #
33213320 # If `index` is out of range, returns `nil`.
33223321 #
3323- # When two Integer arguments `start` and `length` are given, returns a new
3324- # `Array` of size `length` containing successive elements beginning at offset
3325- # `start`:
3322+ # When two Integer arguments `start` and `length` are given, returns a new array
3323+ # of size `length` containing successive elements beginning at offset `start`:
33263324 #
33273325 # a = [:foo, 'bar', 2]
33283326 # a[0, 2] # => [:foo, "bar"]
@@ -3336,7 +3334,7 @@ class Array[unchecked out Elem] < Object
33363334 # a[1, 3] # => ["bar", 2]
33373335 # a[2, 2] # => [2]
33383336 #
3339- # If `start == self.size` and `length >= 0`, returns a new empty `Array` .
3337+ # If `start == self.size` and `length >= 0`, returns a new empty array .
33403338 #
33413339 # If `length` is negative, returns `nil`.
33423340 #
@@ -3347,7 +3345,7 @@ class Array[unchecked out Elem] < Object
33473345 # a[0..1] # => [:foo, "bar"]
33483346 # a[1..2] # => ["bar", 2]
33493347 #
3350- # Special case: If `range.start == a.size`, returns a new empty `Array` .
3348+ # Special case: If `range.start == a.size`, returns a new empty array .
33513349 #
33523350 # If `range.end` is negative, calculates the end index from the end:
33533351 #
@@ -3371,7 +3369,7 @@ class Array[unchecked out Elem] < Object
33713369 # a[4..-1] # => nil
33723370 #
33733371 # When a single Enumerator::ArithmeticSequence argument `aseq` is given, returns
3374- # an `Array` of elements corresponding to the indexes produced by the sequence.
3372+ # an array of elements corresponding to the indexes produced by the sequence.
33753373 #
33763374 # a = ['--', 'data1', '--', 'data2', '--', 'data3']
33773375 # a[(1..).step(2)] # => ["data1", "data2", "data3"]
@@ -3518,6 +3516,9 @@ class Array[unchecked out Elem] < Object
35183516 # When the block returns zero, the order for `a` and `b` is indeterminate, and
35193517 # may be unstable.
35203518 #
3519+ # See an example in Numeric#nonzero? for the idiom to sort more complex
3520+ # structure.
3521+ #
35213522 # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
35223523 #
35233524 def sort : () -> ::Array[Elem]
@@ -3647,7 +3648,7 @@ class Array[unchecked out Elem] < Object
36473648 # rdoc-file=array.c
36483649 # - to_a -> self or new_array
36493650 # -->
3650- # When `self` is an instance of ` Array` , returns `self`.
3651+ # When `self` is an instance of Array, returns `self`.
36513652 #
36523653 # Otherwise, returns a new array containing the elements of `self`:
36533654 #
@@ -3663,7 +3664,7 @@ class Array[unchecked out Elem] < Object
36633664
36643665 # <!--
36653666 # rdoc-file=array.c
3666- # - array. to_ary -> self
3667+ # - to_ary -> self
36673668 # -->
36683669 # Returns `self`.
36693670 #
@@ -4008,7 +4009,7 @@ class Array[unchecked out Elem] < Object
40084009 # [:c3, :b3, :a3]]
40094010 #
40104011 # For an **object** in **other_arrays** that is not actually an array, forms the
4011- # the "other array" as `object.to_ary`, if defined, or as `object.each.to_a`
4012+ # "other array" as `object.to_ary`, if defined, or as `object.each.to_a`
40124013 # otherwise.
40134014 #
40144015 # Related: see [Methods for Converting](rdoc-ref:Array@Methods+for+Converting).
0 commit comments