summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2021-07-29 08:10:20 -0700
committerJeremy Evans <code@jeremyevans.net>2021-07-29 08:10:20 -0700
commit693ce6af0a3c73ae6927ea67e990cd7f778eaac7 (patch)
tree8b6e3d41ffefb04c92e28e83f290142f7df5277c /vm_method.c
parent7564e066ffba6113604628bf01819e3e0af7037e (diff)
Update documentation for ruby2_keywords
Point out that the method should be used for backwards compatibility with code prior to Ruby 3.0 instead of Ruby 2.7. It's still needed in Ruby 2.7. It isn't needed in Ruby 3.0, as the methods using it could switch to delegating both positional and keyword arguments. Add a link to the www.ruby-lang.org web page that goes into detail describing when and how ruby2_keywords should be used.
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/vm_method.c b/vm_method.c
index 182d42dc1a..1950fb1f9d 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -2165,14 +2165,13 @@ rb_mod_private(int argc, VALUE *argv, VALUE module)
* methods.
*
* This should only be used for methods that delegate keywords to another
- * method, and only for backwards compatibility with Ruby versions before
- * 2.7.
+ * method, and only for backwards compatibility with Ruby versions before 3.0.
+ * See https://www.ruby-lang.org/en/news/2019/12/12/separation-of-positional-and-keyword-arguments-in-ruby-3-0/
+ * for details on why +ruby2_keywords+ exists and when and how to use it.
*
* This method will probably be removed at some point, as it exists only
- * for backwards compatibility. As it does not exist in Ruby versions
- * before 2.7, check that the module responds to this method before calling
- * it. Also, be aware that if this method is removed, the behavior of the
- * method will change so that it does not pass through keywords.
+ * for backwards compatibility. As it does not exist in Ruby versions before
+ * 2.7, check that the module responds to this method before calling it:
*
* module Mod
* def foo(meth, *args, &block)
@@ -2180,6 +2179,10 @@ rb_mod_private(int argc, VALUE *argv, VALUE module)
* end
* ruby2_keywords(:foo) if respond_to?(:ruby2_keywords, true)
* end
+ *
+ * However, be aware that if the +ruby2_keywords+ method is removed, the
+ * behavior of the +foo+ method using the above approach will change so that
+ * the method does not pass through keywords.
*/
static VALUE