[Vit-discuss] Top Ruby Projects algorithm?

James Edward Gray II james at grayproductions.net
Fri Aug 25 20:46:21 EDT 2006


On Aug 25, 2006, at 3:31 PM, Gavin Kistner wrote:

>> Array difference might be another good candidate:
>>
>> cities = %w(London Oslo Paris Amsterdam Berlin)
>> visited = %w(Berlin Oslo)
>> puts "I still need to visit the following cities: " + (cities -
>> visited).join(",")
>
> I like that, but (for brevity) I might change it to:
> cities = %w(London Oslo Paris Amsterdam Berlin)
> visited = %w(Berlin Oslo)
> puts "I still need to visit the following cities:", (cities - visited)
>
> The output isn't the same (of course), but it's moderately reasonable,
> and makes the language look a little simpler, IMHO.

I've added this one, since we all seemed to like it.

James Edward Gray II


More information about the vit-discuss mailing list