Class: DefaultInitArray
Direct Known Subclasses
Instance Method Summary collapse
- #[](index) ⇒ Object
-
#initialize(*args, &initblock) ⇒ DefaultInitArray
constructor
A new instance of DefaultInitArray.
Methods inherited from Array
#delete_at_indices, #equality_uniq
Constructor Details
#initialize(*args, &initblock) ⇒ DefaultInitArray
Returns a new instance of DefaultInitArray.
16 17 18 19 |
# File 'lib/graphr/base_extensions.rb', line 16 def initialize(*args, &initblock) super(*args) @initblock = initblock end |
Instance Method Details
#[](index) ⇒ Object
21 22 23 |
# File 'lib/graphr/base_extensions.rb', line 21 def [](index) super(index) || (self[index] = @initblock.call(index)) end |