Method: Rupture::Sequence#reduce

Defined in:
lib/rupture/sequence.rb

#reduce(*args, &fn) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/rupture/sequence.rb', line 180

def reduce(*args, &fn)
  fn ||= args.shift
  Utils.verify_args(args, 0, 1)

  if s = seq
    inject(*args, &fn)
  elsif args.size == 1
    args.first
  else
    fn[] if fn.arity == -1
  end
end