I might have not been clear. it = getItems()[2] does exactly the same thing than lst = getItems(); it = lst[2];
It is not a way to return a single element by a special magic!
It is only a syntactical shortcut.
The second example was another example of shortcut, similar in the sense that the return value is used immediately, without intermediary variable.
It is not a way to return a single element by a special magic!
It is only a syntactical shortcut.
The second example was another example of shortcut, similar in the sense that the return value is used immediately, without intermediary variable.