class Array

Extend core Array by adding {to_proc} which will enable arrays to be treated as functions of their indexes.

Public Instance Methods

to_proc() click to toggle source

Return a proc that takes the index of the array and returns the value at that index or nil if there is no value at the given index.

@return [Proc]

# File lib/invokable/array.rb, line 8
def to_proc
  lambda do |index|
    at(index)
  end
end