Class: DefaultInitArray

Inherits:
Array
  • Object
show all
Defined in:
lib/fsm-0.0.0/graph/base_extensions.rb

Direct Known Subclasses

ArrayOfArrays, ArrayOfHashes

Instance Method Summary collapse

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/fsm-0.0.0/graph/base_extensions.rb', line 16

def initialize(*args, &initblock)
  super(*args)
  @initblock = initblock
end

Instance Method Details

#[](index) ⇒ Object


21
22
23
# File 'lib/fsm-0.0.0/graph/base_extensions.rb', line 21

def [](index)
  super(index) || (self[index] = @initblock.call(index))
end