Class | Pry::HistoryArray |
In: |
lib/pry/history_array.rb
|
Parent: | Object |
A history array is an array to which you can only add elements. Older entries are removed progressively, so that the aray never contains more than N elements.
History arrays are used by Pry to store the output of the last commands.
@example
ary = Pry::HistoryArray.new 10 ary << 1 << 2 << 3 ary[0] # => 1 ary[1] # => 2 10.times { |n| ary << n } ary[0] # => nil ary[-1] # => 9
max_size | [R] | @return [Integer] Maximum amount of objects in the array |
@overload [](index)
@param [Integer] index Index of the item to access. @return [Object, nil] Item at that index or nil if it has been removed.
@overload [](index, size)
@param [Integer] index Index of the first item to access. @param [Integer] size Amount of items to access @return [Array, nil] The selected items. Nil if index is greater than the size of the array.
@overload [](range)
@param [Range<Integer>] range Range of indices to access. @return [Array, nil] The selected items. Nil if index is greater than the size of the array.