Copying and filtering Ruby arrays I'm doing a Ruby exercise to create new arrays with a given filter.


  Copy the values less than 4 in the array stored in the source variable
  into the array in the destination variable.


The editorial solution code is:

def array_copy(source)
  destination = []
  for number in source
    # Add number to destination if number
    # is less than 4
    destination &lt;&lt; number if number &lt; 4
  end
  return destination
end


But, as a beginner, I came up with this solution:

def array_copy(source)
  return source.select {|i| i &lt; 4}
end


Is there any problems with my solution?
I think your answer is perfectly valid and much better than the editorial solution.

I only have two suggestions to improve it further:


variable name i is commonly used for array indexes. Using it instead for array values can confuse the reader of the code.
return is not needed - Ruby functions will implicitly return the value of the last evaluated expression.