select even elements : select « Range « Ruby






select even elements


(1..8).select {|x| x%2==0}    # => [2,4,6,8]: select even elements

 

Related examples in the same category