Class: Enumerator::Lazy
- Inherits:
-
Object
- Object
- Enumerator::Lazy
- Defined in:
- lib/twterm/extensions/enumerator/lazy.rb
Instance Method Summary collapse
Instance Method Details
#scan(initial, sym = nil) ⇒ Object
3 4 5 6 7 8 9 10 |
# File 'lib/twterm/extensions/enumerator/lazy.rb', line 3 def scan(initial, sym = nil) acc = initial Enumerator::Lazy.new(self) do |y, x| acc = sym.nil? ? yield(acc, x) : sym.to_proc.call(acc, x) y << acc end end |