- select
- select
- filter
- grep
Select (filter, grep)
examples/arrays/select.cr
numbers = [10, 20, 7, 21, 5] puts numbers small = numbers.select do |num| num > 10 end puts small puts numbers.select { |num| num > 10 } puts numbers puts "" big = numbers.select! do |num| num < 10 end puts big puts numbers
[10, 20, 7, 21, 5] [20, 21] [20, 21] [10, 20, 7, 21, 5] [7, 5] [7, 5]