Skip to main content
deleted 2 characters in body
Source Link
Mark Thomas
  • 37.6k
  • 11
  • 77
  • 101

Yes, you can use the map command. Here is the short hand version for what you are trying to do:

roasterroster.map(&:user) # if roasterroster = [r1, r2, r3] then the output will be [r1.user, r2.user, r3.user]

You can read more about the map function in the Ruby Array API: http://ruby-doc.org/core-2.0.0/Array.html#method-i-map

Yes, you can use the map command. Here is the short hand version for what you are trying to do:

roaster.map(&:user) # if roaster = [r1, r2, r3] then the output will be [r1.user, r2.user, r3.user]

You can read more about the map function in the Ruby Array API: http://ruby-doc.org/core-2.0.0/Array.html#method-i-map

Yes, you can use the map command. Here is the short hand version for what you are trying to do:

roster.map(&:user) # if roster = [r1, r2, r3] then the output will be [r1.user, r2.user, r3.user]

You can read more about the map function in the Ruby Array API: http://ruby-doc.org/core-2.0.0/Array.html#method-i-map

Source Link
Max
  • 16.1k
  • 20
  • 90
  • 141

Yes, you can use the map command. Here is the short hand version for what you are trying to do:

roaster.map(&:user) # if roaster = [r1, r2, r3] then the output will be [r1.user, r2.user, r3.user]

You can read more about the map function in the Ruby Array API: http://ruby-doc.org/core-2.0.0/Array.html#method-i-map