iOS開發——swift篇&經典文法二十六)文法修正

來源:互聯網
上載者:User

標籤:

 

多項改進

蘋果全新程式設計語言 Swift 迎來了大幅更新,開發人員可以使用 Swift 編寫更好、更安全的應用。新版 Swift 程式設計語言修正了很多開發人員提出的請求。此外,蘋果也更新了介紹 Swift 的iBooks 書籍,反映出新變化。

更新時間:2014-07-07

更新內容:

  • Swift’s Array type now has full value semantics. Updated the information about Mutability of Collections and Arrays to reflect the new approach. Also clarified the Assignment and Copy Behavior for Strings, Arrays, and Dictionaries.
    • Array類型成為了數實值型別,由結構來實現,所以在賦值或者作為參數傳遞的時候會拷貝一個全新的數值,而不像類一樣,僅僅只是傳遞了一個引用。
    • 相應的第九章類與結構中Array和Dictionary的賦值和複製也有更新,翻譯稿儘快推出。

 

  • Array Type Shorthand Syntax is now written as [SomeType] rather than SomeType[].
    • Array的書寫形式由SomeType[]變為了[SomeType]
    • var shoppingList: [String] = ["Eggs", "Milk"]

 

  • Added a new section about Dictionary Type Shorthand Syntax, which is written as [KeyType: ValueType].
    • 字典類型的簡寫形式:[String: String]
    • var airports: [String: String] = ["TYO": "Tokyo", "DUB": "Dublin"]

 

  • Added a new section about Hash Values for Dictionary Key Types.
    • 作為字典類型中鍵的類型,必須是可雜湊的
    • String,Int,Double和Bool類型都是可雜湊的,所以可以作為字典的鍵

 

  • Examples of Closure Expressions now use the global sorted function rather than the global sort function, to reflect the new array value semantics.
    • 閉包運算式使用全域的sorted函數來表現新的數組語義

 

  • Updated the information about Memberwise Initializers for Structure Types to clarify that the memberwise structure initializer is made available even if a structure’s stored properties do not have default values.
    • 結構類型的成員逐一構造方法預設存在
    • 無論結構的屬性是否有初始值都可以直接使用

 

  • Updated to ..< rather than .. for the Half-Closed Range Operator.
    • 左閉右開區間表示中,使用..<替代原有的..
    • 1 ..< 5表示1,2,3,4。1 … 5表示1,2,3,4,5
    • 這種書寫方法更便於理解和使用

 

  • Added an example of Extending a Generic Type.
    • 在擴充中新添加了一個樣本
  

iOS開發——swift篇&經典文法二十六)文法修正

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.