Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 240 Bytes

each_vs_map.md

File metadata and controls

20 lines (14 loc) · 240 Bytes

Each vs map

Let the following each:

users_ids = []
users.each { |user| users_ids << user.id }

It can be simplified to:

users_ids = users.map { |user| user.id }

or even:

users_ids = users.map &:id