Comment on Keyword Arguments: Ruby, Clojure, Common LispparentComments−epochwolf15yHere's an example of how I use the hash as keyword arguments. (Minus the documentation def save_record(record, options={}, &block) return nil if record.nil? options = { :add_params => {}, :as => nil, :without_protection => false, :params => params[record.class.name.underscore.to_sym], :user => current_user, }.update options The important part is: options = {}.update(options)This pattern works very well for providing defaults and some documentation on what options are available. I still document the options before the function.
Comments
Here's an example of how I use the hash as keyword arguments. (Minus the documentation
The important part is: options = {}.update(options)This pattern works very well for providing defaults and some documentation on what options are available. I still document the options before the function.