2008/8/1 Milo Thurston <knirirr / gmail.com>: > Robert Klemme wrote: >> Just one additional remark: if your Arrays grow large you might >> benefit from converting them to Set which has faster lookups. > > > You're right - if I use a Set then the lookup is astonishingly fast by > comparison. > Is it OK to combine arrays and sets, though? For example, I have a Set > of things I need to grep and an array I don't, and these need to be > combined as an array. So, is: > > final = set + array > > ...OK, or do I need to do > > final = set.to_a + array > > ...or even something else? It all depends on what you need. If you need Set semantics, use Sets. If you need lists (maintain a particular order) use Arrays. It all depends. You can easily convert via #to_a and #to_set. But if you are finding yourself converting all the time chances are that you are doing something wrong. :-) Cheers robert -- use.inject do |as, often| as.you_can - without end