Permalink
Browse files

Correct example that did not do what it claimed. Rework explanation.

  • Loading branch information...
1 parent feec225 commit 4c27ad0c23d8d8889221d5234496b39f1cc9bdb8 @r00k r00k committed with fxn Feb 26, 2011
Showing with 5 additions and 5 deletions.
  1. +5 −5 activesupport/lib/active_support/core_ext/hash/reverse_merge.rb
@@ -6,14 +6,14 @@ class Hash
# options.reverse_merge! :size => 25, :velocity => 10
# end
#
- # Using <tt>merge</tt>, the above example would look as follows:
+ # The default <tt>:size</tt> and <tt>:velocity</tt> are only set if the +options+ hash passed in doesn't already
+ # have the respective key.
+ #
+ # As contrast, using Ruby's built in <tt>merge</tt> would require writing the following:
#
# def setup(options = {})
- # { :size => 25, :velocity => 10 }.merge(options)
+ # options = { :size => 25, :velocity => 10 }.merge(options)
# end
- #
- # The default <tt>:size</tt> and <tt>:velocity</tt> are only set if the +options+ hash passed in doesn't already
- # have the respective key.
def reverse_merge(other_hash)
other_hash.merge(self)
end

0 comments on commit 4c27ad0

Please sign in to comment.