Module: EnumerableWithScanLeft
- Defined in:
- lib/scan_left/enumerable_with_scan_left.rb
Overview
Optional refinement which refines Enumerable to add a #scan_left method, in order to provide a more natural syntax in comparison to explicitly creating instances of the ScanLeft class.
Without using this refinement, we wrap Enumerables in ScanLeft instances:
ScanLeft.new([1,2,3]).scan_left(0, &:+) # => [0, 1, 3, 6]
Using this refinement, we can call #scan_left directly on any Enumerable:
[1,2,3].scan_left(0, &:+) # => [0, 1, 3, 6]