50] for index in 0..<array.count { print(array[index]) } Closed'range'operator for elementNumber in 1...array.count { print("This is the element no. \(elementNumber):" + "\(array[elementNumber - 1])") } Slices'of'Swi+','Antonio'Bello','@ant_bello 55
main loop 4 **/ 5 for elementNumber in 1...array.count { 6 7 /* Prints the element # and its value */ 8 print("This is the element no. \(elementNumber):" + 9 "\(array[elementNumber - 1])") 10 11 // No return value here 12 } 13 */ Slices'of'Swi+','Antonio'Bello','@ant_bello 56
Int) -> Float let result = normal(4, "string", 7) func curried(a: Int)(b: String)(c: Int) -> Float let fa = curried(4) // Returns a function accepting a parameter of type `String` let fb = fa("string") // Returns a function accepting a parameter of type `Int` let result = fb(7) // Returns a `Float` Slices'of'Swi+','Antonio'Bello','@ant_bello 57
let name = json["name"] if let name = JsonString(name) { let email = json["email"] if let email = JsonString(email) { let age = json["age"] if let age = JsonInt(age) { let user = User(name: name, email: email, age: age) } } } Slices'of'Swi+','Antonio'Bello','@ant_bello 60