Creates a new empty array, my_array = Array.new, Returns the number of items the array contains, my_array.length, access the item at a given position within an array, my_array[1], Deletes the item at a given index and returns it, my_array.delete_at(1), iterate over all elements in an array, my_array.each do |item| puts item end, Returns the very first item of the array, my_array.first, Returns the very last item of the array, array.last, Returns a boolean, whether the array contains a certain element or not, array.include?(item), Removes the last item of the array and returns it, my_array.pop, Adds an item to the end of the array, my_array.push(4) my_arry<<4, Returns a copy of the array with the elements in reverse order, my_array.reverse, Returns a sorted copy of the array, [5, 2, 4].sort, Returns a copy of the array with duplicates removed, [1, 1, 2, 2].uniq

Leaderboard

Visual style

Options

Switch template

Continue editing: ?