Sha256: d60aa3ef5a437003ec4203c0be89f42b1a7baef9d8cc0f621b6b3b9e6f77a386

Contents?: true

Size: 255 Bytes

Versions: 4

Compression:

Stored size: 255 Bytes

Contents

class Hash
  # Swap the values of a pair of keys.
  #
  #   require 'facet/hash/swap!'
  #
  #   {:a=>1,:b=>2}.swap!  #=> {:a=>2,:b=>1}
  #
  def swap!( key1, key2 )
    tmp = self[key1]
    self[key1] = self[key2]
    self[key2] = tmp
    self
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
facets-0.6.3 lib/facet/hash/swap!.rb
facets-0.7.0 lib/facet/hash/swap%21.rb
facets-0.7.1 lib/facet/hash/swap%21.rb
facets-0.7.2 lib/facet/hash/swap%21.rb