[ruby-core:66723] [ruby-trunk - Feature #10571] Keyword arguments with local variable

From: mail@...
Date: 2014-12-05 09:57:59 UTC
List: ruby-core #66723
Issue #10571 has been updated by gogo tanaka.


@Yukihiro Matsumoto san
Thank you so much. It does make sense, I need to deepen understanding your language.

@Nobuyoshi Nakada san
Thank you for your information. I think `define_method`, moreover `block`  is really really awesome.

----------------------------------------
Feature #10571: Keyword arguments with local variable
https://bugs.ruby-lang.org/issues/10571#change-50321

* Author: gogo tanaka
* Status: Closed
* Priority: Low
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
It's kind of curiosity. As far as I searched, I couldn't get sensible reason.
Please give me information if you have free time.

```ruby
class MyClass
  var = 'test'
  def my_method(kwd_var: var)
    p kwd_var
  end
end

MyClass.new.my_method
#=> NameError: undefined local variable or method `var' for #<MyClass:0x007f91520a15c8>
```

I've expected above code is same as below code.

```ruby
class MyClass
  def my_method(kwd_var: 'test')
    p kwd_var
  end
end

MyClass.new.my_method
#=> "test"
```

Take your time. Thanks.



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

In This Thread

Prev Next