Finding duplicates in an array

an application i am working on sends emails to an array of users. it is
possible for the user’s email to actually be in the array more than
once.

i don’t have a real strong grasp of the ruby syntax yet, but is there an
easy way to go through and either remove all of the duplicates or at
least only send an email to that user once?

i just found something in the reference guide on the ruby site.

previously i was using something like:

emailArr << newEmail

but i saw this:

emailArr | [newEmail]

is this what i should do when creating the array? or is there a better
way to accomplish what i need?

On Monday, June 19, 2006, at 9:38 PM, Josh K. wrote:


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

new_array = some_array.uniq

_Kevin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs