get first 3 element in array ruby code example
Example 1: ruby select first n elements from array
array = ['toto','titi','tata','tutu']
array.first(2) # => ['toto', 'titi']
Example 2: ruby get the first element of an array
array = [1, 2, 3]
array.first
=> 1