Class: Set

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

Overview

Extend stdlib Set object by adding #to_proc which will allow a set to be treated as a function of the membership of it’s elements.

Instance Method Summary collapse

Instance Method Details

#to_procProc

Return a proc that takes an value and return true if the value is an element of the set, but returns false otherwise.

Returns:



10
11
12
13
14
# File 'lib/invokable/set.rb', line 10

def to_proc
  lambda do |element|
    include?(element)
  end
end