Reputation: 193
I am learning Ruby on RubyMonk. And I cannot perform this lesson:
We have a method called filter
that accepts an explicitly passed block. We look to the block to tell us whether a value from the array should be accepted or rejected.
The Array#select
method does exactly this but requires an implicit block. Try converting the explicit block into an implicit block and passing it on to Array#select
.
def filter(array, block)
return array.select # Your code here
end
What I should do?
Upvotes: 0
Views: 786
Reputation: 1652
def filter(array, block)
return array.select(&block)
end
Note that the answers for each problem are accessible from the page. Simply click the link titled "See the Solution"
Upvotes: 1