Does `Module#ruby2_keywords` return `nil` or `self`?
The RDoc says that it returns
ruby2_keywords(method_name, ...) -> self
This seems consistent with other methods which accept method names, e.g.,
But it actually returns
TestKeywordArguments#test_ruby2_keywords also has 2
Which is intentional?
Updated by mame (Yusuke Endoh) about 2 months ago
- Assignee changed from mame (Yusuke Endoh) to jeremyevans0 (Jeremy Evans)
I think either is fine. This is a weak opinion, but it looks safer to me not to change the actual return value. jeremyevans0 (Jeremy Evans) Do you have an opinion?
Updated by jeremyevans0 (Jeremy Evans) about 2 months ago
zverok (Victor Shepelev) wrote in #note-4:
Shouldn't it actually return method's name?.. For things like
private ruby2_keywords def my_method # .... end
That was not my intention, though I don't object to it if someone else wants to make that change. Note that it would have to return an array of symbols, not a single symbol, since
ruby2_keywords accepts arbitrary arguments. Also, it raises the question whether
ruby2_keywords should include a method symbol if it doesn't mark the method and issues a warning instead.
Updated by Eregon (Benoit Daloze) about 2 months ago
Since ruby2_keywords is often used conditionally, I think there is little value for it to return Symbols:
private ruby2_keywords def foo seems very long and hard to read.
Updated by nagachika (Tomoyuki Chikanaga) 24 days ago
- Backport changed from 2.5: DONTNEED, 2.6: DONTNEED, 2.7: REQUIRED, 3.0: REQUIRED to 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONE, 3.0: REQUIRED
ruby_2_7 ea222b05571741f36b59f615c2e83b3adafbd398 merged revision(s) 49d3830f44031174ad450a0ea1cdcdf0eabf9d0e.
Updated by naruse (Yui NARUSE) 19 days ago
- Backport changed from 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONE, 3.0: REQUIRED to 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONE, 3.0: DONE
ruby_3_0 38f9c832e812f96fd06ca73688ff2baa528c119c merged revision(s) 49d3830f44031174ad450a0ea1cdcdf0eabf9d0e.