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
0%
Arrays
Share
Share
by
Vwandeler
Edit Content
Print
Embed
More
Assignments
Leaderboard
Show more
Show less
This leaderboard is currently private. Click
Share
to make it public.
This leaderboard has been disabled by the resource owner.
This leaderboard is disabled as your options are different to the resource owner.
Revert Options
Match up
is an open-ended template. It does not generate scores for a leaderboard.
Log in required
Visual style
Fonts
Subscription required
Options
Switch template
Show all
Open results
Copy link
QR code
Delete
Continue editing:
?