[swift-evolution] Proposal: Python's indexing and slicing

Amir Michail a.michail at me.com
Fri Dec 18 06:42:04 CST 2015


Examples:

>>> l=[1,2,3,4,5]
>>> l[-1]
5
>>> l[-2]
4
>>> l[2:4]
[3, 4]
>>> l[2:]
[3, 4, 5]
>>> l[-2:]
[4, 5]
>>> l[:3]
[1, 2, 3]
>>> l[::2]
[1, 3, 5]
>>> l[::]
[1, 2, 3, 4, 5]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151218/4b1759c5/attachment.html>


More information about the swift-evolution mailing list