修改代码块儿bug

This commit is contained in:
CoCodeIsLife
2016-10-24 14:52:47 +08:00
parent aef3d29f2c
commit b38540f643

View File

@ -240,7 +240,7 @@ print(total)
func greet(name: String, day: String) -> String { func greet(name: String, day: String) -> String {
return "Hello \(name), today is \(day)." return "Hello \(name), today is \(day)."
} }
greet("Bob", day: "Tuesday") greet(name:"Bob", day: "Tuesday")
``` ```
> 练习: > 练习:
@ -274,7 +274,7 @@ func calculateStatistics(scores: [Int]) -> (min: Int, max: Int, sum: Int) {
return (min, max, sum) return (min, max, sum)
} }
let statistics = calculateStatistics([5, 3, 100, 3, 9]) let statistics = calculateStatistics(scores:[5, 3, 100, 3, 9])
print(statistics.sum) print(statistics.sum)
print(statistics.2) print(statistics.2)
``` ```
@ -313,7 +313,7 @@ returnFifteen()
函数是第一等类型,这意味着函数可以作为另一个函数的返回值。 函数是第一等类型,这意味着函数可以作为另一个函数的返回值。
```swift ```swift
func makeIncrementer() -> (Int -> Int) { func makeIncrementer() -> ((Int) -> Int) {
func addOne(number: Int) -> Int { func addOne(number: Int) -> Int {
return 1 + number return 1 + number
} }
@ -326,7 +326,7 @@ increment(7)
函数也可以当做参数传入另一个函数。 函数也可以当做参数传入另一个函数。
```swift ```swift
func hasAnyMatches(list: [Int], condition: Int -> Bool) -> Bool { func hasAnyMatches(list: [Int], condition: (Int) -> Bool) -> Bool {
for item in list { for item in list {
if condition(item) { if condition(item) {
return true return true