title: Ruby , I couldn't find how the following code actually works
body: <pre><code>class ArrayMine &lt; Array
  
    def join( sep = $,, format = "%s" )
  
      collect do |item|
        sprintf( format, item )
      end.join( sep )
    end
  
  end
  
  =&gt; rooms = ArrayMine[3, 4, 6]    #i couldn't understand how this line works
  
  print "We have " + rooms.join( ", ", "%d bed" ) + " rooms available."
  </code></pre>
  
  <p>i have tried the same with String, but it comes up with an error.</p>
  
  <pre><code>    thank you...
  </code></pre>