From: Yuri Leikind Date: 2001-11-14T01:29:31+09:00 Subject: [ruby-talk:25029] Set class in Ruby Hello all Ruby coders, Using Ruby for various tasks at work I often had to use hashes as sets. One day I coded a Set class as a sublass of Hash. Writing a Set class is no big deal, a piece of cake, actually, but it saves me a _lot_ of time, as I can do such high-level operations as subtracting sets, intersecting them and so on. I thought: Why doesn't Ruby have Set as a built-in class? Smalltalk does have it. Before asking you this question I searched this newsgroup archives and found this interesting thread: http://groups.google.com/groups?hl=en&th=17df256263eb21&rnum=1 Particularly, Dave Thomas suggested: > Wouldn't it be clearer to define a new Set type, rather than new > operations? [cut] > However, sometimes it's convenient to have Sets, collections where > there's only ever one of each element. These have different semantics > to arrays: they are not necessarily ordered, attempting to add an > element doesn't necessarily increase the size, and so on. So, why doesn't Ruby have Set as a built-in class? -- Best regards, Yuri Leikind