From: Peter Hickman Date: 2010-07-07T18:36:32+09:00 Subject: Re: Hashes don't allow preceding commas by design? --001485f5b02e237ed2048ac8e7ed Content-Type: text/plain; charset=ISO-8859-1 On 7 July 2010 10:15, Josh Cheek wrote: > I think that I feel this should not be the case, because I feel that the > interpreter should not consider any of it complete since it is inside of an > incomplete hash. > > However, these examples have me so unsure of what is supposed to be what > that I can't construct a response illustrating this. Please double check > these examples. > The structure of a has assignment could be either: 1: => a = { :fred => 42 } or 1: => a = 2: => { 3: => :fred => 42 4: => } Here line 1 is incomplete so it treats line 2 as a continuation. Line 2 says 'here is the start of a hash' and is also incomplete. So line 3 is seen as a continuation of line 2. Line 3 is complete in that it is a valid statement that can be found inside a hash declaration but the parser is still looking for the closing } to match the opening { from line 2. So although line 3 is a complete valid statement it is part of lines 1 and 2 which is an incomplete hash declaration. So line 4 is taken to be a continuation of lines 1, 2 and 3 and finally completes the statement that started on line 1. --001485f5b02e237ed2048ac8e7ed--