+ 1
Ruby task- Help my explain why I receive output in this =7
What is the output of this code? *a,b= [1,2,3,4] Puts a[b-2] +b # output= 7 I just wh ant understand why?
5 Respostas
+ 4
Андрей Рыбаков
a is a list
And a[2] means value at index 2 which is 3
As index start from 0..
a[0]=1
a[1]=2
a[2]=3
+ 3
Yes. Indira's answer is an extremely clear answer.
0
ok, But how did this expression turn into this
a[2] --->3?
a=1+2+3=6
6[2]--->6/2?