Guest User

Untitled

a guest
Aug 16th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. ## a
  2. def get_bars(foos=[])
  3. bars = []
  4.  
  5. foos.each do |foo|
  6. bars = bars | foo.bars
  7. end
  8.  
  9. bars
  10. end
  11.  
  12. ## b
  13. def get_bars(foos=[])
  14. foos.map(&:bars).inject{|a, b| a | b}
  15. end
  16.  
  17. ## c
  18. def get_bars(foos=[])
  19. foos.map(&:bars).flatten.uniq
  20. end
Add Comment
Please, Sign In to add comment