"James T. Vradelis" <jvradelis / mediaone.net> writes: | I'd like to see: | | (k) Hash#[], Array#[] | | as in: | | myHash = {'one' => 1, 'two' => 2, 'three' => 3} | | myHash['one','two','three'] -> [1,2,3] | | and | | myArray = [1,2,3,4,5] | myArray[4,2,3] -> [5,3,4] | | I realize that this latter conflicts with: | | Array#[<beginning index>, <number of elements>] | | but that functionality is duplicated by: | | Array#[<beginning index>..<beginning index + number of elements - 1>] | | anyway. You probably already know this, but the Array functionality you mention already exists: [1,2,3,4,5].indexes(4,2,3) -> [5, 3, 4] or if you prefer giving it an array: [1,2,3,4,5].indexes(*[4,2,3]) -> [5, 3, 4] Although I agree that the syntax you propose is nicer. How about the following, which would not be in conflict with the current overloading of Array#[]? myArray = [1,2,3,4,5] myArray[[4,2,3]] That is, arr[anArray] -> aSubArray. You could even loosen the requirements to arr[anEnumerable], which would generalize the current semantics for arr[aRange]. I guess this would only work for hashes if you didn't allow Arrays as keys. -- http://www.dfan.org