From: Ryan Davis Date: 2011-03-26T14:39:09+09:00 Subject: Re: critique please On Mar 25, 2011, at 20:12 , Charles Oppenheimer wrote: > Folks, the first ruby I've written that I actually needed (I shortened > the actual strings I was comparing, which were very long). So > thought I'd ask, before I write the next one - is there a more elegant > way to do this, or conventions that are usually used? your code looks fine. convention-wise, I'd recommend using underscores to make your variables more idiomatic and readable, eg: global_campaigns. I'd also recommend off of naming things with types ala hungarian notation and friends. Usually the fact that the variable is plural is sufficient to show it is some sort of collection. > globalcampaigns = "item1, item2, item3, item4, item5" > premiercampaigns = "item1, item2" > basiccampaigns = "item3, item4" > > > globalarray = globalcampaigns.split(",") > premarray = premiercampaigns.split(",") > basicarray = basiccampaigns.split(",") > > #globalarray.each {|elt| puts elt} > > combo = premarray | basicarray > diff = globalarray - combo > > diff.each {|elt| puts elt}