Skip to content

Commit

Permalink
Showing 2 changed files with 20 additions and 9 deletions.
9 changes: 0 additions & 9 deletions spec/truffle/tags/core/enumerator/lazy/grep_v_tags.txt

This file was deleted.

20 changes: 20 additions & 0 deletions truffle/src/main/ruby/core/enumerator.rb
Original file line number Diff line number Diff line change
@@ -390,6 +390,26 @@ def grep(pattern)
end
end

def grep_v(pattern)
if block_given?
Lazy.new(self, nil) do |yielder, *args|
val = args.length >= 2 ? args : args.first
unless pattern === val
# Regexp.set_block_last_match # TODO BJF Aug 2, 2016 Investigate for removal
yielder.yield yield(val)
end
end
else
Lazy.new(self, nil) do |yielder, *args|
val = args.length >= 2 ? args : args.first
unless pattern === val
# Regexp.set_block_last_match # TODO BJF Aug 2, 2016 Investigate for removal
yielder.yield val
end
end
end
end

def map
raise ArgumentError, 'Lazy#{map,collect} requires a block' unless block_given?

0 comments on commit 4bebf84

Please sign in to comment.