Skip to content

Commit c5b4907

Browse files
author
Juan Antonio Karmy
committed
Upgraded book to Swift 3.0
1 parent 2be0e47 commit c5b4907

File tree

119 files changed

+1308
-2105
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+1308
-2105
lines changed

02_Basic Operators.playground/section-1.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ for index in 0..<array.count{
4848
}
4949

5050
// Enumerate array with index and value, C loop will be removed soon
51-
for (index, value) in array.enumerate() {
51+
for (index, value) in array.enumerated() {
5252
print("value \(value) at index \(index)")
5353
}

03_Collection Types.playground/playground.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 7 deletions
This file was deleted.

03_Collection Types.playground/section-1.swift renamed to 04_Collection Types.playground/section-1.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ shoppingList += ["Bird", "Shark"]
3737

3838
shoppingList[1...3] = ["Bananas", "Apples", "Strawberries"] //Replace several items at once
3939

40-
shoppingList.insert("Maple Syrup", atIndex: 0) //Inserts element at index
40+
shoppingList.insert("Maple Syrup", at: 0) //Inserts element at index
4141

42-
let mapleSyrup = shoppingList.removeAtIndex(0) // Returns removed item
42+
let mapleSyrup = shoppingList.remove(at: 0) // Returns removed item
4343

4444
var emptyArray = [Int]() //Initialize empty array
4545
var anotherEmptyArray = [] //Also valid
46-
var array = [Int](count: 3, repeatedValue: 0) //Initalizes an array of length 3 with zeros
46+
var array = [Int](repeating: 0, count: 3) //Initalizes an array of length 3 with zeros
4747

4848
var compoundArray = array + emptyArray
4949

50-
var reversedShoppingList: [String] = shoppingList.reverse()
50+
var reversedShoppingList: [String] = shoppingList.reversed()
5151

5252
reversedShoppingList.removeLast() // Removes last item. Remove the first with removeFirst(). No returned value.
5353
reversedShoppingList.popLast() // Pops the last item, removing it from the array and also returning it. Note that if the array is empty, the returned value is nil.
@@ -68,7 +68,7 @@ if let airportName = airports["DUB"] { //Subscript always returns optional in ca
6868
}
6969

7070
airports["LAX"] = nil
71-
airports.removeValueForKey("LAX") //Both remove the key-value pair
71+
airports.removeValue(forKey: "LAX") //Both remove the key-value pair
7272

7373
//Iterating over the whole dictionary
7474
for (airportCode, airportName) in airports {

04_Control Flow.playground/playground.xcworkspace/contents.xcworkspacedata

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)