Class: Hash

Inherits:
Object show all
Defined in:
lib/srs_game.rb

Overview

class String

Instance Method Summary collapse

Instance Method Details

#+(add) ⇒ Object

Add two hashes. Does not overwrite pre-existing values.



113
114
115
116
117
118
# File 'lib/srs_game.rb', line 113

def +(add)
  temp = {}
  add.each { |k, v| temp[k] = v}
  self.each { |k, v| temp[k] = v}
  temp
end

#<<(add) ⇒ Object

Add two hashes. Overwrites pre-existing values, and is destructive.



121
122
123
124
125
126
# File 'lib/srs_game.rb', line 121

def <<(add)
  temp = {}
  self.each { |k, v| temp[k] = v}
  add.each { |k,v| temp[k] = v}
  replace temp
end