Module: Gemmy::Patches::ProcPatch::InstanceMethods::Multiply

Defined in:
lib/gemmy/patches/proc_patch.rb

Overview

(a * b).call(4) #=> 6 (b * a).call(4) #=> 4

Instance Method Summary collapse

Instance Method Details

#*(x) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/gemmy/patches/proc_patch.rb', line 55

def *(x)
  if Integer===x
    # collect times
    c = []
    x.times{|i| c << call(i)}
    c
  else
    # compose procs
    lambda{|*a| self[x[*a]]}
  end
end