Logo

Programming-Idioms

History of Idiom 165 > diff from v55 to v56

Edit summary for version 56 by programming-idioms.org:
Restored version 54

Version 55

2020-04-27, 01:55:48

Version 56

2020-04-27, 19:54:11

Idiom #165 Last element of list

Assign to variable x the last element of list items.

Idiom #165 Last element of list

Assign to variable x the last element of list items.

Code
local x = items.at(0)
Code
local x = items[#items]
Comments bubble
Gets the last sequential item
Comments bubble
Gets the last sequential item
Doc URL
https://www.lua.org/manual/5.3/manual.html#3.4.7
Doc URL
https://www.lua.org/manual/5.3/manual.html#3.4.7