Username Username - 11 months ago 33
Ruby Question

How do I loop through elements of a bash array variable passed to a Ruby script via terminal?

I have a Bash file called

ruby testScript.rb $arr

And here's

ARGV.each{|a| p a}

When I run
in the terminal, I get this output:


I want my Ruby script to loop through all elements in the Bash array variable
. How do I fix my code to do this?


In the bash script, pass the array like this:

ruby testScript.rb ${arr[@]}