Skip to content

Commit d4bbb52

Browse files
author
Lillian Zhang
committed
Implement and untag Enumerable#filter_map
1 parent 6ed78bd commit d4bbb52

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

spec/tags/core/enumerable/filter_map_tags.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/main/ruby/truffleruby/core/enumerable.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,19 @@ def reject
924924
ary
925925
end
926926

927+
def filter_map
928+
return to_enum(:filter_map) { enumerator_size } unless block_given?
929+
930+
ary = []
931+
each do
932+
o = Primitive.single_block_arg
933+
v = yield(o)
934+
ary << v if v
935+
end
936+
937+
ary
938+
end
939+
927940
def reverse_each(&block)
928941
return to_enum(:reverse_each) { enumerator_size } unless block_given?
929942

0 commit comments

Comments
 (0)