in some video i saw next string:
User.select(:email).map(&:email)
tell me plz what does it means
i know that string
User.select(:email)
is selecting only the email column from the db, but i don’t understand what means
.map(&:email)
and can we change User.select(:email) to User.pluck(:email)
because from tutorial i understand thats the same methods. is this true?
The
map(&:email)maps your array ofUsers to a map of string containing only the users’ emails.The Array.map iterates over your current array, and creates a new one, by calling the parameter block, and storing the result in the new array. It is equivalent with this: