Print contents of array in oneline
<p>I am new to ruby and was trying out with arrays.i want to print the array in single line.
this is the block of code(please ignore any errors)</p>

<pre><code>array=[]

puts "Choose an option: ","1.Push, 2.Pop, 3.Display Length"
choice=gets.to_i
while choice!=4
if choice==1
    puts "enter Number of elements to be pushed"
    n=gets.to_i
    n.times do
      puts "Enter element"
    el=gets.to_s
    array.push el
    end
  puts array
elsif choice==2
    puts array.pop

elsif choice==3
    puts array.length

else
  puts "invalid"
end
end
</code></pre>

<p>when I print my array in <code>if choice==1</code>i get all the outputs on different lines,
example</p>

<pre><code>hello
i
am
beginner
to
ruby
</code></pre>

<p>is there anyway to put the output in single line?
i.e <code>hello i am beginner to ruby</code></p>

<p>EDIT: I have even tried using <code>puts array.join(' ')</code>, but that too doesnt work.</p>