From: Zsban Ambrus Date: 2004-04-18T04:47:39+09:00 Subject: Re: Hash, ==, key-value comparison On Fri, Apr 16, 2004 at 09:23:00AM +0900, nobu.nokada@softhome.net wrote: > Hi, > ... > > I feel Hash#=== would test membership, i.e., alias for > Hash#key?. > > -- > Nobu Nakada I'd agree with that. This way you could easily test for many possible values in a case statement. Note that if there are many vaes to match with, then a hash may be more efficent then a "when" with a comma-delimited list, as long as the hash is calculated only once. (Of course, if there are multiple "when" branches like that, a single hash that does all the matching or probably a hash of proces or lambdas (I don't quite know the fine point of distinguishing these) is better.) Let me mention how this will work in perl6. In perl6, the =~ operator will do something similar to ruby's ===, that is, it is used in the when clauses, it matches numeric or string data, regexps, and classes just like === in ruby (and thus does not automatically coerce a string to a regexp as =~ in per5 or ruby). When it meets a hash or an array on either side, it mathces each key (element of array) with the other side until it finds a match. To do this with an array is quite unneccesarry I think, but it is good for a haash.