Skip to content

Commit 58f2017

Browse files
committed
Replace each with each_with_object at norris parse method
1 parent 2335aa3 commit 58f2017

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

Training/Easy/chuck_norris.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,15 @@ def split_series(array)
2828
end
2929

3030
def norris_parse(series_array)
31-
result = ''
32-
series_array.each do |a|
33-
result += if a[0].zero?
31+
parsed = series_array.each_with_object('') do |a, result|
32+
result << if a[0].zero?
3433
'00 '
3534
else
3635
'0 '
3736
end
38-
result += '0' * a[1] + ' '
37+
result << '0' * a[1] + ' '
3938
end
40-
result.strip
39+
parsed.strip
4140
end
4241

4342
def start

0 commit comments

Comments
 (0)