Ruby Array Question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Ruby Array Question

ruby arrays, I'm trying to understand how x=[1 2 3] y=[3 4 5] res=x|y puts res[2] ... How did they come up with 2?

21st Jun 2017, 3:16 PM
Sharon Lewis
Sharon Lewis - avatar
3 Answers
+ 7
please state your question more clearly .what is the problem.Are you not getting the output or are you getting the wrong output ? @Sharon
21st Jun 2017, 3:47 PM
Sri Lakshmi
Sri Lakshmi - avatar
+ 7
moreover in ruby, the elements inside array are separated with commas U should declare array like this :- x=[1,2,3] y=[3,4,5] Any more doubts, feel free to ask @Sharon Lewis
21st Jun 2017, 3:50 PM
Sri Lakshmi
Sri Lakshmi - avatar
0
I understand that the array starts with zero, but the third element doesn't give me 2.
21st Jun 2017, 3:27 PM
Sharon Lewis
Sharon Lewis - avatar