Is it good to use `reverse_merge!` on the optional hash argument of a method?
- Dominant language
- Ruby
- Stars
- 3.9k
- Forks
- 756
- PR merge metrics
- No merged PRs in 30d
Description
I found an example in this guide
```
def obliterate(things, options = {})
default_options = {
:gently => true, # obliterate with soft-delete
:except => [], # skip obliterating these things
:at => Time.now, # don't obliterate them until later
}
options.reverse_merge!(default_options)
...
end
```
I'm wondering whether this is a good practice. When you use this method, the input options hash might be modified by `reverse_merge!` method, which, in my opinion, is very error-prone process in a big project.
Contributor guide
Research direction
Start by locating the guide containing the `obliterate` example and review how optional hash arguments and `reverse_merge!` are discussed. Check the surrounding documentation and any related style guidance; done means the question has a settled recommendation and the guide reflects it clearly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100