solution.highest_count_words_across_lines
is an array of strings. When you do this: solution.highest_count_words_across_lines.map(&:highest_wf_words)
you are calling highest_wf_words
on each of the array items, and that method is not defined for a String (that is what the error message says).
I guess that in fact you want something like this instead:
words_found = solution.highest_count_words_across_lines.map( |x| highest_wf_words(x)).flatten
UPDATE
if the aim of your mapping is for the words_found
only to include highest_wf_words
, assuming that this is an array, here’s how you can do it:
words_found = solution.highest_count_words_across_lines.flatten & highest_wf_words
.
[1,2,3] & [2,3,4]
=> [2, 3]
1
solved Rspec pass test in ruby testing