Replace Loop with Collection Closure Method

You are processing the elements of a collection in a loop.

Replace the loop with a collection closure method.

managers = []
employees.each do |e|
  managers << e if e.manager?
end 

image/svg+xml

managers = employees.select {|e| e.manager?}
  

Naming: I've stopped using the term "Collection Closure Method" in favor of "Collection Lambda"