From: Trans Date: 2005-08-06T00:51:06+09:00 Subject: Re: new block notation David A. Black wrote: > > Nah, just use the _collection_ brackets for both array and hash. The > > parser can tell them apart: > > > > # array > > [ a, b, c ] > > > > # hash > > [ a=>x, b=>y, c=>z ] > > [ a: x, b: y, c: z ] > > I don't like to have to scan visually for a separator in order to know > what the [ meant. That seems ad hoc and fragile. > David, Yes, contrary to you other post, there are already "scanning" to be done. Eg. def ameth(n=nil,&b) # ... end Is it a hash or a block? ameth {[1032,12,34,89].collect{|x|x*7+3}.join('->');7+15**2} ameth {[1032,12,34,89].collect{|x|x*7+3}.join('->'),7+15**2} I'm sure others can provide even better examples. But the point really is that the "=>" (or ": ") is a equally as important visual cue that stands out in the scanning, and is usually just a few charactes in. Personally I have never written a hash without it. Thus using [ ... ] in place of { ... } would at the least be no more or less difficult. But would prove better in one respect --that the purely comma hash noation would no longer be valid and a "=>" or ":" has to always be used. That's a readability improvement in my mind. T. P.S. Might it help clear up ambiguity of '(1,2,3)' which is currently a syntax error? Why can't that be parsed as an array?