Skip to content

Commit

Permalink
Showing 2 changed files with 25 additions and 4 deletions.
4 changes: 0 additions & 4 deletions spec/truffle/tags/core/enumerable/chunk_while_tags.txt

This file was deleted.

25 changes: 25 additions & 0 deletions truffle/src/main/ruby/core/enumerable.rb
Original file line number Diff line number Diff line change
@@ -69,6 +69,31 @@ def chunk(&original_block)
end
end

def chunk_while(&block)
block = Proc.new(block)
Enumerator.new do |yielder|
accumulator = nil
prev = nil
each do |*elem|
elem = elem[0] if elem.size == 1
if accumulator == nil

This comment has been minimized.

Copy link
@nirvdrum

nirvdrum Aug 25, 2016

Contributor

The rest of the code in this file calls nil? instead. I'd just update to match.

This comment has been minimized.

Copy link
@bjfish

bjfish Aug 25, 2016

Contributor

Fixed at 5f4db31 , thanks

accumulator = [elem]
prev = elem
else
start_new = block.yield(prev, elem)
if !start_new
yielder.yield accumulator if accumulator
accumulator = [elem]
else
accumulator << elem
end
prev = elem
end
end
yielder.yield accumulator if accumulator
end
end

def collect
if block_given?
ary = []

0 comments on commit 6fd0b57

Please sign in to comment.