title: Ruby: Iterate the result from method using block
body: <p>Now I have a ruby like this:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>def fizzbuzz(numSize)
      result = []
      1.upto(numSize) do |num|
          if num % 15 == 0
              result &lt;&lt; "FizzBuzz"
          elsif num % 3 == 0
              result &lt;&lt; "Fizz"
          elsif num % 5 == 0
              result &lt;&lt; "Buzz"
          else
              result &lt;&lt; num.to_s
          end
      end
      result
  end
  
  print fizzbuzz(10) {|item| "-#{i1tem}-"}</code></pre>
  </div>
  </div>
  </p>
  <p>If I want to print the result like this:
  [&quot;-1-&quot;, &quot;-2-&quot;, &quot;-Fizz-&quot;, &quot;-4-&quot;, &quot;-Buzz-&quot;, &quot;-Fizz-&quot;, &quot;-7-&quot;, &quot;-8-&quot;, &quot;-Fizz-&quot;, &quot;-Buzz-&quot;]</p>
  <p>What can I modify my code in method fizzbuzz if I can not change the code:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>print fizzbuzz(10) {|item| "-#{i1tem}-"}</code></pre>
  </div>
  </div>
  </p>
  <p>Thanks</p>