From: Dan Schmidt Date: 2001-02-22T01:40:03+09:00 Subject: [ruby-talk:11245] Re: Summary: RCR #U002 - proper new name for indexes "James T. Vradelis" 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#[, ] | | but that functionality is duplicated by: | | Array#[..] | | 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