Method: Hash#displace
- Defined in:
- lib/casual_support/hash/displace.rb
#displace(key, value) ⇒ Hash
Associates key
with value
, and returns key
‘s previously associated value. If key
had no previously associated value, returns Hash#default.
20 21 22 23 24 |
# File 'lib/casual_support/hash/displace.rb', line 20 def displace(key, value) old_value = self[key] self[key] = value old_value end |