Forum: Ruby Re: Confusion Over Keyword Arguments

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Berger, Daniel (Guest)
on 2006-03-02 17:09
(Received via mailing list)
> >> From: Yukihiro Matsumoto [mailto:matz@ruby-lang.org]
> >>
> > end
> or
>
>    a = foo(  (baz = 5), (bar = 2)  )
>
> ??

Second one.

Dan
Cb48ca5059faf7409a5ab3745a964696?d=identicon&s=25 unknown (Guest)
on 2006-03-02 17:17
(Received via mailing list)
On Fri, 3 Mar 2006, Berger, Daniel wrote:

>>    foo baz = 5, bar = 2
>>
>>    a, b = foo(baz = 5), (bar = 2)
>>
>> or
>>
>>    a = foo(  (baz = 5), (bar = 2)  )
>>
>> ??
>
> Second one.

but that's a problem no?  number two is the same as this

   baz = 5
   bar = 2
   a = foo baz, bar

see, when on writes

   foo baz = 5, bar = 2

it's ambiguous if those assignments are part of a method call or not.
bar
escpecitally, it could easily be considered an assignment statement
(bar=2)
that's part of a parrallel assignment statement.

or am i missing something?

-a
F3b7b8756d0c7f71cc7460cc33aefaee?d=identicon&s=25 Daniel Berger (Guest)
on 2006-03-02 17:23
(Received via mailing list)
ara.t.howard@noaa.gov wrote:
>>>
>>> ??
>>
>>
>> Second one.
>
>
> but that's a problem no?  number two is the same as this
>
>   baz = 5
>   bar = 2
>   a = foo baz, bar

No, then they become positional.  That's the same as foo 2, 5.

> see, when on writes
>
>   foo baz = 5, bar = 2
>
> it's ambiguous if those assignments are part of a method call or not.  bar
> escpecitally, it could easily be considered an assignment statement (bar=2)
> that's part of a parrallel assignment statement.
>
> or am i missing something?

The parser just has to be trained well enough. :)

That being said, perhaps using '=' as a keyword operator would just
cause too
much confusion amongst the Ruby community.  I know some people hate
changing
behavior based on context.

Regards,

Dan
This topic is locked and can not be replied to.