Actions
Bug #13022
closedNested array syntax error returns nil
Description
If you leave out a comma in a nested array, ruby returns nil
instead of raising a SyntaxError. Is this expected behavior?
- Create a nested array with a missing comma:
[[1,3], [5,6] [11, 15], [17,22]] #=> [[1, 3], nil, [17, 22]]
Updated by jeremyevans0 (Jeremy Evans) over 7 years ago
Yes, this is expected behavior. Ruby parses this as:
[[1,3], [5,6].[](11, 15), [17,22]]
And Array#[] returns nil if the starting index (11) is out of range.
Updated by marcandre (Marc-Andre Lafortune) over 7 years ago
- Status changed from Open to Rejected
Actions
Like0
Like0Like0