From: David Fayram Date: 2003-07-27T07:18:46+09:00 Subject: Re: Set doesn't have [] instance method On Saturday, July 26, 2003, at 3:08 PM, Josef 'Jupp' Schugt wrote: > Saluton! > > * Gavin Sinclair; 2003-07-26, 20:13 UTC: >> It should, shouldn't it? It's meant to combine the fast lookup of >> Hash with the convenience of Array, yet the most important method Hash >> and Array have in common, Set lacks! >> >> $ irb >> irb(main):001:0> require 'set' >> => true >> irb(main):002:0> s = Set[1,2,3] >> => # >> irb(main):003:0> s.include? 1 >> => true >> irb(main):004:0> s[1] >> NoMethodError: undefined method `[]' for # >> from (irb):4 >> from :0 > > Ruby follows the principle of least surprise. Am I the only one to be > stupefied if '[]' would exist for a set? Definitely not. When I first saw it, it took me a second to even realize what the heck it should do. - Dave "paradox" Fayram Developer / Idealist