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



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/gemmy/patches/proc_patch.rb', line 43

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