Commits

Jasper Van der Jeugt committed 39fcb10

More idiomatic code for the ruby fold benchmark

Comments (0)

Files changed (1)

tests/benchmarks/ruby/fold.rb

     file.each_line do |line|
       # If we encounter an empty line, we reformat and dump the current
       # paragraph
-      if line.strip.empty? then
+      if line.strip.empty?
         puts fold_paragraph(paragraph, max_width)
         puts
         paragraph = []
   width = str.length
 
   paragraph.drop(1).each do |word|
-    if width + word.length + 1 <= max_width then
-      str += ' ' + word
+    if width + word.length + 1 <= max_width
+      str << ' ' + word
       width += word.length + 1
     else
-      str += "\n" + word
+      str << "\n" + word
       width = word.length
     end
   end