Skip to content

Commit

Permalink
Prefer keyword arguments over optional arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
bbatsov committed Sep 16, 2018
1 parent a48c9cb commit 508e506
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,21 @@ Translations of the guide are available in the following languages:
some_method # => false
some_method(bar: true) # => true
```
* <a name="keyword-arguments-vs-optional-arguments"></a>
Prefer keyword arguments over optional arguments.
<sup>[[link](#keyword-arguments-vs-optional-arguments)]</sup>

```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
```

* <a name="keyword-arguments-vs-option-hashes"></a>
Use keyword arguments instead of option hashes.
Expand Down

0 comments on commit 508e506

Please sign in to comment.