Ruby Arrays form a core foundation in programming in Ruby, and most languages in fact. It is used so much that it would be beneficial to know and even memorize some of the most commonly used methods for arrays. If you want to know more about Ruby Arrays, we have [an article about them](https://guide.freecodecamp.org/ruby/ruby-arrays).
For the purpose of this guide, our array will be as follows:
``` ruby
array = [0, 1, 2, 3, 4]
```
#### .length
The .length method tallies the number of elements in your array and returns the count:
The flatten method can be used to take an array that contains nested arrays and create a one-dimensional array:
``` ruby
array = [1, 2, [3, 4, 5], [6, 7]]
array.flatten
=> [1, 2, 3, 4, 5, 6, 7]
```
#### .join
The .join method returns a string of all the elements of the array separated by a separator parameter. If the separator parameter is nil, the method uses an empty string as a separator between strings.
``` ruby
array.join
=> "1234"
array.join("*")
=> "1*2*3*4"
```
#### .each
The .each method iterates over each element of the array, allowing you to perform actions on them.
The .map method is the same as the .collect method. The .map and .collect methods iterate over each element of the array, allowing you to perform actions on them. The .map and .collect methods differ from the .each method in that they return an array containing the transformed elements.
``` ruby
array.map { |element| element * 2 }
puts element
end
=>
0
2
4
6
8
```
#### .uniq
The .uniq method takes in an array containing duplicate elements, and returns a copy of the array containing only unique elements--any duplicate elements are removed from the array.
The .concat method appends the elements from an array to the original array. The .concat method can take in multiple arrays as an argument, which will in turn append multiple arrays to the original array.