for an arbitrary iterator that's not possible unless you first save the results of every iteration into a seq.
Though say if you iterate about a seq, you can do this: for i, item in pairs mySeq: if i == mySeq.len-1: echo "last" Run or if you iterate over a table: var i = 0 for k, v, in pairs myTable: if i == myTable.len-1: echo "last" i += 1 Run