- 1
Challenge or quiz question
What is the output of this code? arr = [1, 6, 4, 2] print arr.take(arr.last) answer is [1, 6] I don't get it. Last should't it be 2? There are plenty of challenge questions I don't understand. Not sure if I should be posting new questions for all challenge explanations or just use one new question thread?
2 Answers
+ 2
Thank you John Wells. I will post future questions related to such topics here. I just posted another one before I saw this.
0
arr.last returns 2 and arr.take(2) yields the first two elements. It makes sense to continue using this thread.