From: "trans. (T. Onoma)" Date: 2004-12-15T01:15:44+09:00 Subject: Re: Array#at(selector,...) On Tuesday 14 December 2004 10:17 am, trans. (T. Onoma) wrote: | Is there good reason to have two different methods for this? | | array.at(index) | array.values_at(selector,... ) To help answer my own question. A problem arises with output on single element results: a = [1,2,3,4,5] a.at(0) #=> 1 a.values_at(0) #=> [1] The only alternatives I see for unification would be to have #at take an Array or ignore nil: a.at([0]) #=> [1] a.at(0,nil) #=> [1] But barring that (or a better solution), my REAL PROBLEM boils down to how best to implement a method related to this but that doesn't have the same difficulty. For example (completely contrived): class Array def part(n=nil) if n values_at(0..n) else at(0) end end end Is it better to have two methods instead --an #at_part and a #values_at_part? Personally I prefer the single method but that seems to go against the at/values_at grain. So that's why I'm inquiring into it. | And then | | array.delete_at(index) | | Can't this take selector instead? This still seems reasonable. T.