Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

revises Enumerable#pluck in AS guide

  • Loading branch information...
commit ee45823072cb21cfca623ff45792ef381774e32d 1 parent baa93a1
@vijaydev vijaydev authored
View
2  railties/guides/source/active_support_core_extensions.textile
@@ -2055,7 +2055,7 @@ NOTE: Defined in +active_support/core_ext/enumerable.rb+.
h4. +pluck+
-Plucks the value of the passed method for each element and returns the result as an array
+The +pluck+ method collects the value of the passed method for each element and returns the result as an array.
<ruby>
people.pluck(:name) # => [ "David Heinemeier Hansson", "Jamie Heinemeier Hansson" ]

5 comments on commit ee45823

@dmitriy-kiriyenko

Why is this method anyway? Same as map(&:name).

@samuelkadolph

@dmitriy-kiriyenko It's not, pluck restricts the select part of the query as well. Where just map(&:name) wouldn't do that.

@dmitriy-kiriyenko

@samuelkadolph, come on, it's not activerecord, it's activesupport. This is a Enumerable extension, not the ActiveRecord::Relation extension. So it's a direct analogue for map(&:name).

@samuelkadolph

You even commented on a382d60. How can you not see the reason for this method? In case you can't figure it out, it's so you can call pluck on a relation or enumerable and not have to worry about using map(&:name) if it's not actually a relation.

@dmitriy-kiriyenko

Yeah, I got it. To get the api integrity.

Please sign in to comment.
Something went wrong with that request. Please try again.