From 810ed2d9b53f4134f5902bb7888f81287d24bd41 Mon Sep 17 00:00:00 2001
From: Piotr Szmielew
Date: Tue, 30 Jul 2019 12:59:39 +0200
Subject: [PATCH 1/4] Optional Keyword Arguments
When using optional keyword arguments, put them at the end of the parameters list.
Otherwise, it's much harder to spot optional arguments there, if they're hidden somewhere in the middle.
---
README.adoc | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/README.adoc b/README.adoc
index 1bd283724..4b85e5bfa 100644
--- a/README.adoc
+++ b/README.adoc
@@ -2548,6 +2548,24 @@ some_method('w', 'x', 'y') # => 'y, 2, w, x'
some_method('w', 'x', 'y', 'z') # => 'y, z, w, x'
----
+=== Optional Keyword Arguments [[optional-keywordarguments]]
+
+When using optional keyword arguments, put them at the end of the parameters list.
+When looking through the source, you expect required arguments at the beginning of parameters list and optional arguments at the end.
+
+[source,ruby]
+----
+# bad
+def some_method(first: false, second:, third: 10)
+ # body omitted
+end
+
+# good
+def some_method(second:, first: false, third: 10)
+ # body omitted
+end
+----
+
=== Boolean Keyword Arguments [[boolean-keyword-arguments]]
Use keyword arguments when passing boolean argument to a method.
From a3b065e026df4db2e28ab5f46acc4c1eded9d880 Mon Sep 17 00:00:00 2001
From: Piotr Szmielew
Date: Thu, 12 Sep 2019 08:16:23 +0100
Subject: [PATCH 2/4] Changes after CR
---
README.adoc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.adoc b/README.adoc
index 4b85e5bfa..bbd05d496 100644
--- a/README.adoc
+++ b/README.adoc
@@ -2548,7 +2548,7 @@ some_method('w', 'x', 'y') # => 'y, 2, w, x'
some_method('w', 'x', 'y', 'z') # => 'y, z, w, x'
----
-=== Optional Keyword Arguments [[optional-keywordarguments]]
+=== Keyword Arguments Order [[keyword-arguments-order]]
When using optional keyword arguments, put them at the end of the parameters list.
When looking through the source, you expect required arguments at the beginning of parameters list and optional arguments at the end.
From 82e6c7875d08dad47ea22b03aa7afe991e0fc663 Mon Sep 17 00:00:00 2001
From: Phil Pirozhkov
Date: Mon, 22 Feb 2021 21:21:47 +0300
Subject: [PATCH 3/4] fixup! Reword the guideline
---
README.adoc | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/README.adoc b/README.adoc
index bbd05d496..44ca7b08c 100644
--- a/README.adoc
+++ b/README.adoc
@@ -2550,8 +2550,7 @@ some_method('w', 'x', 'y', 'z') # => 'y, z, w, x'
=== Keyword Arguments Order [[keyword-arguments-order]]
-When using optional keyword arguments, put them at the end of the parameters list.
-When looking through the source, you expect required arguments at the beginning of parameters list and optional arguments at the end.
+Put required keyword arguments before optional keyword arguments.
[source,ruby]
----
From 38b2c94bc3215ae556673b8d195fd0e6e263b391 Mon Sep 17 00:00:00 2001
From: Piotr Szmielew
Date: Tue, 25 May 2021 14:09:01 +0200
Subject: [PATCH 4/4] Update README.adoc
---
README.adoc | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.adoc b/README.adoc
index 44ca7b08c..7f8d2d719 100644
--- a/README.adoc
+++ b/README.adoc
@@ -2548,19 +2548,19 @@ some_method('w', 'x', 'y') # => 'y, 2, w, x'
some_method('w', 'x', 'y', 'z') # => 'y, z, w, x'
----
-=== Keyword Arguments Order [[keyword-arguments-order]]
+=== Keyword Arguments Order
-Put required keyword arguments before optional keyword arguments.
+Put required keyword arguments before optional keyword arguments. Otherwise, it's much harder to spot optional arguments there, if they're hidden somewhere in the middle.
[source,ruby]
----
# bad
-def some_method(first: false, second:, third: 10)
+def some_method(foo: false, bar:, baz: 10)
# body omitted
end
# good
-def some_method(second:, first: false, third: 10)
+def some_method(foo:, bar: false, baz: 10)
# body omitted
end
----