We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c5e8063 commit 6f0d45bCopy full SHA for 6f0d45b
chapter06/example_replace_loop_with_collection_closure_method.rb
@@ -1,19 +1,16 @@
1
class ExampleReplaceLoopWithCollectionClosureMethod
2
def employee_managers
3
- managers = employees.select {|e| e.manager?}
+ managers = employees.select { |e| e.manager? }
4
managers
5
end
6
7
def employee_offices
8
- offices = employees.collect {|e| e.office}
+ offices = employees.collect { |e| e.office }
9
offices
10
11
12
def manager_office
13
- manager_offices = []
14
- employees.each do |e|
15
- manager_offices << e.office if e.manager?
16
- end
+ manager_offices = employees.select { |e| e.manager? }.collect { |e| e.office }
17
manager_offices
18
19
0 commit comments