From: Cezary Date: 2011-06-06T03:45:12+09:00 Subject: [ruby-core:36768] Re: [Ruby 1.9 - Feature #4830] Provide Default Variables for Array#each and other iterators On Mon, Jun 06, 2011 at 01:07:05AM +0900, Lazaridis Ilias wrote: > > Issue #4830 has been updated by Lazaridis Ilias. > > > Nobuyoshi Nakada wrote: > > At Sun, 5 Jun 2011 17:23:26 +0900, > > Lazaridis Ilias wrote in [ruby-core:36750]: > > > for arrays: use "item" by default > > > for hashes: use "key" and "value" by default > > > > There is no way to tell what class the receiver is to the > > parser. Your proposal needs very big change under the hood. Maybe something like special variables, e.g. $1, $2, ... instead? That would remove the need to check the type, but reduce readability, etc. Personally, I prefer to be able to give specific names other than "key", "value", "item", like "person", "date", "sex", etc. Might be useful for more generic code, OTOH. -- Cezary Baginski