I am just starting in Ruby, I am facing the following issue.
ip_array = [1.1.1.1,2.2.2.2]
for i in 0..1
puts `ping #{ip_array[#{i}]}`
end
This gives me an error: unexpected IDENTIFIER, expecting ']'
however this works
ip_array = [1.1.1.1,2.2.2.2]
for i in 0..1
puts `ping #{ip_array[i]}`
end
Can someone explain this, I think think #{ip_array[#{i}]}
is more correct than #{ip_array[i]}