What does .select do again?


#1


https://www.codecademy.com/en/courses/ruby-beginner-en-L3ZCI/1/1?curriculum_id=5059f8619189a5000201fbcb


multiples_of_3 = Proc.new do |n|
  n % 3 == 0
end

(1..100).to_a.select(&multiples_of_3)


#2

.select() is a collection method that maps the values in a range object that meet the criterion specificied by the Proc passed in to it.

multiples_of_3 returns true or false, and select() will map only the values in the range that end up true in return from the proc. The output array will contain only

[3, 6, 9, .., 93, 96, 99]