[前][次][番号順一覧][スレッド一覧]

ruby-changes:57420

From: Yusuke <ko1@a...>
Date: Sat, 31 Aug 2019 07:05:43 +0900 (JST)
Subject: [ruby-changes:57420] Yusuke Endoh: a1e588d1a7 (master): NEWS: Hash-to-keywords automatic conversion is now warned

https://git.ruby-lang.org/ruby.git/commit/?id=a1e588d1a7

From a1e588d1a73e3d72cd9ce6a2516ada9baeb77861 Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Sat, 31 Aug 2019 07:03:27 +0900
Subject: NEWS: Hash-to-keywords automatic conversion is now warned

A follow up for 16c6984bb9..b5b3afadfa.  [Feature #14183]

diff --git a/NEWS b/NEWS
index 0769f59..1714f96 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,25 @@ sufficient information, see the ChangeLog file or Redmine https://github.com/ruby/ruby/blob/trunk/NEWS#L19
 * Method reference operator, <code>.:</code> is introduced as an
   experimental feature.  [Feature #12125] [Feature #13581]
 
+* Preparations for the redesign of keyword arguments towards Ruby 3.
+  [Feature #14183]
+  * Automatic conversion from a Hash to keyword arguments is deprecated:
+    when a method call passes a Hash at the last argument, and when the
+    called method accepts keywords, it is warned.
+    Please add a double splat operator.
+
+     def foo(key: 42); end; foo({key: 42})   # warned
+     def foo(**kw);    end; foo({key: 42})   # warned
+     def foo(key: 42); end; foo(**{key: 42}) # OK
+     def foo(opt={});  end; foo( key: 42 )   # OK
+
+  * Non-symbol keys are allowed as a keyword argument.
+
+     def foo(**kw); p kw; end; foo("str" => 1) #=> {"str"=>1}
+
+* Automatic conversion of keyword arguments and positional ones is warned.
+  [Feature #14183]
+
 * Proc.new and proc with no block in a method called with a block is warned
   now.
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]