I have a Ruby array containing some string values. I need to:
- Find all elements that match some predicate
- Run the matching elements through a transformation
- Return the results as an array
Right now my solution looks like this:
def example
matchingLines = @lines.select{ |line| ... }
results = matchingLines.map{ |line| ... }
return results.uniq.sort
end
Is there an Array or Enumerable method that combines select and map into a single logical statement?