Project

General

Profile

Actions

Bug #13022

closed

Nested array syntax error returns nil

Added by harrywhelchel (Harry Whelchel) over 7 years ago. Updated over 7 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:78584]

Description

If you leave out a comma in a nested array, ruby returns nil instead of raising a SyntaxError. Is this expected behavior?

  1. 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

Also available in: Atom PDF

Like0
Like0Like0