class Array def Filter result = [] each do |e| result << e if yield(e) end result end end arr = [1,2,3,4,5] p arr.Filter { |e| e.odd? } p arr.Filter { |e| e.even? }
To embed this project on your website, copy the following code and paste it into your website's HTML: