Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/classes.rb

Instance Method Summary collapse

Instance Method Details

#insert_at_index(index, key, value) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/classes.rb', line 79

def insert_at_index(index, key, value)
    return self[key] = value if index >= size

    temp_array = to_a
    temp_array.insert(index, [key, value])
    replace(temp_array.to_h)
end