Swift Style by Erica Sadun

Swift Style by Erica Sadun

Author:Erica Sadun
Language: eng
Format: epub
Tags: Pragmatic Bookshelf
Publisher: Pragmatic Bookshelf

Dictionary Keys and Values

Iterate dictionaries using keys and values rather than enumerating them. Dictionaries naturally produce key/value pairs that better lend themselves to immediate use and avoid accessing tuples by their offsets:

​ ​for​ (key, value) ​in​ dict { ​// yes​

​ print(key, value)

​ }

​ ​for​ item ​in​ dict { ​// no​

​ print(item.0, item.1)

​ }

​ ​for​ (​_​, item) ​in​ dict.enumerated() { ​// extra no​

​ print(item.0, item.1)

​ }



Loading...
Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Web Analytics