write

ARGF.write(string) â integer Instance Public methods Writes string if inplace mode.

[]

[](*args) Class Public methods Returns a new array populated with the given objects. Array.[]( 1, 'a', /^A/ ) # => [1, "a", /^A/] Array[ 1, 'a', /^A/ ] # => [1, "a", /^A/] [ 1, 'a', /^A/ ] # => [1, "a", /^A/]

new

Array.new(size=0, obj=nil)Array.new(array)Array.new(size) {|index| block } Class Public methods Returns a new array. In the first form, if no arguments are sent, the new array will be empty. When a size and an optional obj are sent, an array is created with size copies of obj. Take notice that all elements will reference the same object obj. The second form creates a copy of the array passed as a parameter (the array is generated by calling #to_ary on the parameter). first_array

try_convert

Array.try_convert(obj) â array or nil Class Public methods Tries to convert obj into an array, using to_ary method. Returns the converted array or nil if obj cannot be converted for any reason. This method can be used to check if an argument is an array. Array.try_convert([1]) #=> [1] Array.try_convert("1") #=> nil if tmp = Array.try_convert(arg) # the argument is an array elsif tmp = String.try_convert(arg) # the argument is a string end

&

ary & other_ary â new_ary Instance Public methods Set Intersection â Returns a new array containing elements common to the two arrays, excluding any duplicates. The order is preserved from the original array. It compares elements using their hash and eql? methods for efficiency. [ 1, 1, 3, 5 ] & [ 1, 2, 3 ] #=> [ 1, 3 ] [ 'a', 'b', 'b', 'z' ] & [ 'a', 'b', 'c' ] #=> [ 'a', 'b' ] See also #uniq.

*

ary * int â new_aryary * str â new_string Instance Public methods Repetition â With a String argument, equivalent to ary.join(str). Otherwise, returns a new array built by concatenating the int copies of self. [ 1, 2, 3 ] * 3 #=> [ 1, 2, 3, 1, 2, 3, 1, 2, 3 ] [ 1, 2, 3 ] * "," #=> "1,2,3"

+

ary + other_ary â new_ary Instance Public methods Concatenation â Returns a new array built by concatenating the two arrays together to produce a third array. [ 1, 2, 3 ] + [ 4, 5 ] #=> [ 1, 2, 3, 4, 5 ] a = [ "a", "b", "c" ] a + [ "d", "e", "f" ] a #=> [ "a", "b", "c", "d", "e", "f" ] See also #concat.

-

ary - other_ary â new_ary Instance Public methods Array Difference Returns a new array that is a copy of the original array, removing any items that also appear in other_ary. The order is preserved from the original array. It compares elements using their hash and eql? methods for efficiency. [ 1, 1, 2, 2, 3, 3, 4, 5 ] - [ 1, 2, 4 ] #=> [ 3, 3, 5 ] If you need set-like behavior, see the library class Set.

<<

ary Instance Public methods AppendâPushes the given object on to the end of this array. This expression returns the array itself, so several appends may be chained together. [ 1, 2 ] << "c" << "d" << [ 3, 4 ] #=> [ 1, 2, "c", "d", [ 3, 4 ] ]

&lt;=&gt;

ary other_ary â -1, 0, +1 or nil Instance Public methods Comparison â Returns an integer (-1, 0, or +1) if this array is less than, equal to, or greater than other_ary. nil is returned if the two values are incomparable. Each object in each array is compared (using the <=> operator). Arrays are compared in an âelement-wiseâ manner; the first two elements that are not equal will determine the return value for the whole comparison. If all the values are equal, then the ret