From e48e13e9043faef46fc0508ba39f857347c2dfdb Mon Sep 17 00:00:00 2001 From: Carl Date: Sat, 14 Oct 2023 23:13:42 +0200 Subject: [PATCH] Simplify example --- exercises/practice/word-count/.meta/src/example.cr | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/exercises/practice/word-count/.meta/src/example.cr b/exercises/practice/word-count/.meta/src/example.cr index cb724b92..f43beac7 100644 --- a/exercises/practice/word-count/.meta/src/example.cr +++ b/exercises/practice/word-count/.meta/src/example.cr @@ -3,9 +3,7 @@ module WordCount result = Hash(String, Int32).new sentence.split(/[\t, \s, \n,]+/).each do |word| word = word.downcase.gsub(/[^\w\s']/, "").gsub(/^\'+|\'+$/, "") - if word == "" - next - end + next if word.empty? result[word] = result.has_key?(word) ? result[word] + 1 : 1 end result