3 ms·
Ruby 2.0 introduced named parameters with default values and 2.1 introduced required named parameters. These are useful. For example, there are cases where you
by gkop 12y ago
Ruby 2.0 introduced named parameters with default values and 2.1 introduced required named parameters. These are useful.
For example, there are cases where you can replace options hashes with named parameters and get rid of guard clauses for key presence as well as lines that assign default values to keys in the options hash. And you don't have to index an options hash of course. The splat operator can be used to pass upstream options hashes to downstream methods taking named parameters so you can just refactor the downstream-most methods taking the options hash and get all these benefits.
- jxf 12y agoThis is true, and is a good counterexample to my point since I do use these on an everyday basis.