From 508e5062905831c318148b9002eb96f5a98b5524 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Sun, 16 Sep 2018 07:45:31 +0300 Subject: [PATCH] Prefer keyword arguments over optional arguments --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 4f9916f7d..7b75e2021 100644 --- a/README.md +++ b/README.md @@ -918,6 +918,21 @@ Translations of the guide are available in the following languages: some_method # => false some_method(bar: true) # => true ``` +* + Prefer keyword arguments over optional arguments. +[[link](#keyword-arguments-vs-optional-arguments)] + + ```Ruby + # bad + def some_method(a, b = 5, c = 1) + # body omitted + end + + # good + def some_method(a, b: 5, c: 1) + # body omitted + end + ``` * Use keyword arguments instead of option hashes.