Sha256: 18425d2e951c19f34f1ab8c914cdf0bdb5d56487ca64fefd0b570635ef2b8fdf

Contents?: true

Size: 263 Bytes

Versions: 27

Compression:

Stored size: 263 Bytes

Contents

class Hash

  # Swap the values of a pair of keys in place.
  #
  #   {:a=>1,:b=>2}.swap!(:a,:b)  #=> {:a=>2,:b=>1}
  #
  # CREDIT: Gavin Sinclair

  def swap!(key1, key2)
    tmp = self[key1]
    self[key1] = self[key2]
    self[key2] = tmp
    self
  end

end

Version data entries

27 entries across 26 versions & 3 rubygems

Version Path
facets-glimmer-3.2.0 lib/core/facets/hash/swap.rb
facets-3.1.0 lib/core/facets/hash/swap.rb
facets-3.0.0 lib/core/facets/hash/swap.rb
facets-2.9.3 lib/core/facets/hash/swap.rb
facets-2.9.2 lib/core/facets/hash/swap.rb
facets-2.9.2 src/core/facets/hash/swap.rb
facets-2.9.1 lib/core/facets/hash/swap.rb
facets-2.9.0 lib/core/facets/hash/swap.rb
facets-2.9.0.pre.2 lib/core/facets/hash/swap.rb
facets-2.9.0.pre.1 lib/core/facets/hash/swap.rb
facets-2.8.4 lib/core/facets/hash/swap.rb
facets-2.8.3 lib/core/facets/hash/swap.rb
facets-2.8.2 lib/core/facets/hash/swap.rb
facets-2.8.1 lib/core/facets/hash/swap.rb
facets-2.8.0 lib/core/facets/hash/swap.rb
facets-2.7.0 lib/core/facets/hash/swap.rb
facets-2.6.0 lib/core/facets/hash/swap.rb
facets-2.4.0 lib/facets/hash/swap.rb
facets-2.4.1 lib/facets/hash/swap.rb
facets-2.4.4 lib/core/facets/hash/swap.rb