Ruby: Case-Insensitive Array Comparison -


just found out comparison case-sensitive..anyone know case-insensitive way of accomplishing same comparison?

cardreferral.all.map(&:email) - cardsignup.all.map(&:email) 

i don't think there "direct" way minus operator, if don't mind getting results in lowercase, can this:

cardreferral.all.map(&:email).map(&:downcase) - cardsignup.all.map(&:email).map(&:downcase) 

otherwise you'll have manually comparison using find_all or reject:

signups = cardsignup.all.map(&:email).map(&:downcase) referrals = cardreferral.all.map(&:email).reject { |e| signups.include?(e.downcase) } 

i'd suggest reading reference of ruby's standard types might come code this. example, "programming ruby 1.9" has methods of enumerable object explained starting on page 487 (find_all on page 489).


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -