Re:Ruby 2.1.3 is released
by gkop on Friday September 19, 2014 @11:53AM
(#8341033)
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.
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.