From: martindemello@... (Martin DeMello) Date: 2002-09-24T18:40:16+09:00 Subject: Re: select and select GOTO Kentaro wrote in message news:<200209231328.g8NDSsND040379@miso.k.notwork.org>... > At Mon, 23 Sep 2002 21:33:05 +0900, > Martin DeMello wrote: > > Has anyone suggested 'values'? array.values(1,2,3) sounds reasonably > > natural, as does hash.values(key1, key2, key3). > > See http://ruby-talk.org/50932 oops - yes, anything with a plural noun would fail requirement 2, since you'd expect the entire list when no argument was given. How about getval (and, for symmetry, setval)? A bonus would be that there might be cases where a.each_index {|i| a.setval(i,f(i))} looks nicer than a.each_index {|i| a[i]=f(i)} The drawback is that using 'getval' rather than 'getvals' doesn't suggest that multiple arguments are accepted. The problem I have with 'pick' (and friends like 'sift' and 'glean') is that it seems to call for a criterion rather than an index list, and therefore be more a synonym of 'select' than of 'indices' Another option I like is 'extract', especially since it seems to fit the four cited common cases (array, hash, matchdata and struct). Though perhaps that suggest something more along the lines of {k1 => v1, k2 => v2, k3 => v3}.extract(k1,k3) = {k1 => v1, k3 => v3} martin