+ 1
I'm misunderstanding something...
Why would the output be false for the array -1?
5 Antworten
+ 10
@Rachel.
a[-1] is used to access the variable in the list from the end. So, a[-1] is the same as a[3] which is false.
Similarly, a[-2] =15.88
This flexibility in indexing is very useful when you code.
+ 7
Could you explain; post a code maybe?
+ 1
yes,
In the language Ruby, we have the array.
arr=[5,"Dave",15.88,false]
I am going to skip to the portion that I don't understand the output to, which is puts arr [-1] #false.
I could go in circles about why I don't understand. :(
+ 1
Thank you.
+ 1
I also found the note that references your answer. thank you :)