Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/invokable/array.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#to_procProc

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.

Returns:



8
9
10
11
12
# File 'lib/invokable/array.rb', line 8

def to_proc
  lambda do |index|
    at(index)
  end
end