Project

General

Profile

Actions

Bug #10870

closed

Hash Literal Declined As First Argument

Added by NorthernLights (Imran "") about 9 years ago. Updated about 9 years ago.

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

Description

Hi,

When a hash literal is passed as first argument to a method, Ruby throws a syntax error.
Example code:

def foo *args
  p args
end

foo 'Hello'
foo 123
foo ['Hello', 123]
foo {:hello => 123}   # Syntax Error: Unexpected =>  Expecting }

However, shifting hash literal over to second place, somehow makes it all legal.

foo 'Unnecessary 1st Argument', {:hello => 123}     # Error gone

Cheers.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0