[Vit-discuss] Top Ruby Projects algorithm?

Gavin Kistner gavin.kistner at anark.com
Fri Aug 25 16:31:56 EDT 2006


> 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.


More information about the vit-discuss mailing list