Module: XKeys::Set_Auto
Overview
Extended set ([]=) with automatic selection of hash keys or array indexes
Instance Method Summary collapse
-
#[]=(*args) ⇒ Object
Auto-vivify nested hash and/or array trees using extended hash key/array index assignment syntax.
Methods included from Set_
Instance Method Details
#[]=(*args) ⇒ Object
Auto-vivify nested hash and/or array trees using extended hash key/array index assignment syntax. Nil keys and integer keys create nested arrays as needed. Other keys create nested hashes as needed.
root[key1, ..., keyN] = value
135 136 137 138 139 |
# File 'lib/xkeys.rb', line 135 def []= (*args) super *args unless _xset(*args) { |key| key == nil || key.is_a?(Integer) } args[-1] end |