Jump to content

The ultimate community for Ruby on Rails developers.


Pluck vs. select and map

  • Please log in to reply
No replies to this topic

#1 Ohm



  • Moderators
  • 529 posts
  • LocationCopenhagen

Posted 09 February 2014 - 09:51 PM

I just wrote a quick blogpost about the difference between pluck and map on Rails models.


The blogpost can be found here: http://ohm.sh/2014/0...and-select.html


When using only map, you end up creating a lot of full fletched ruby objects, which you might not want, but with pluck, you'll only create dummy objects from which you can grab your data. pluck does exactly the same as map and select used together.

  • james likes this

Blog: http://ohm.sh | Twitter: @madsohm | Work: Lokalebasen.dk

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users