Your code has an extra curly brace (bug) :p but your analysis of the problem is correct. To explain a little further when you use the last command it will set the position pointer of the array you are traversing to the last entry, which of course means that the array has been fully "traversed" or that there are no more elements to look at.