From: ko1@...
Date: 2017-10-10T07:11:18+00:00
Subject: [ruby-core:83190] [Ruby trunk Feature#13979] Ruby doesn't give error on keyword arguments that you can't refer to

Issue #13979 has been updated by ko1 (Koichi Sasada).


> `Binding#local_variable_get` does not encourage to use such arguments.

But `Binding#local_variable_get` is introduced for this purpose :p


----------------------------------------
Feature #13979: Ruby doesn't give error on keyword arguments that you can't refer to
https://bugs.ruby-lang.org/issues/13979#change-67134

* Author: asterite (Ary Borenszweig)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
You can't use keywords as names for normal arguments. For example all of these give a syntax error:

~~~ruby
def foo(class); end
def foo(def); end
def foo(if); end
# ... other keywords too
~~~

The reason is that there's no way to refer to these names because they are keywords.

However, we can use these names for keyword arguments. All of these work:

~~~ruby
def foo(class: 1); end
def foo(def: 1); end
def foo(if: 1); end
~~~

But I think they should give a syntax error, because for example I can't refer to the argument "class" in the first line (same reason why the first snippet gives a syntax error).



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>