Skip to content

Commit

Permalink
Generalise 1..n word loop
Browse files Browse the repository at this point in the history
  • Loading branch information
kerryb committed Jul 15, 2009
1 parent e10845f commit 8be9301
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions 1.rb
Expand Up @@ -8,8 +8,9 @@ module StringExtensions
def phrases(number)
words = split
all_strings = words
all_strings += extract_phrases(words, 2)
all_strings += extract_phrases(words, 3)
(2..words.size).each do |number_of_words|
all_strings += extract_phrases(words, number_of_words)
end
all_strings[0, number].map {|s| "'#{s}'"}.join(', ')
end

Expand Down

0 comments on commit 8be9301

Please sign in to comment.