From b38540f6436e5b7a9ebae3b16b45c387fab05d11 Mon Sep 17 00:00:00 2001 From: CoCodeIsLife Date: Mon, 24 Oct 2016 14:52:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81=E5=9D=97?= =?UTF-8?q?=E5=84=BFbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/chapter1/02_a_swift_tour.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/chapter1/02_a_swift_tour.md b/source/chapter1/02_a_swift_tour.md index 5d8d07d2..a34ee03b 100755 --- a/source/chapter1/02_a_swift_tour.md +++ b/source/chapter1/02_a_swift_tour.md @@ -240,7 +240,7 @@ print(total) func greet(name: String, day: String) -> String { 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) } -let statistics = calculateStatistics([5, 3, 100, 3, 9]) +let statistics = calculateStatistics(scores:[5, 3, 100, 3, 9]) print(statistics.sum) print(statistics.2) ``` @@ -313,7 +313,7 @@ returnFifteen() 函数是第一等类型,这意味着函数可以作为另一个函数的返回值。 ```swift -func makeIncrementer() -> (Int -> Int) { +func makeIncrementer() -> ((Int) -> Int) { func addOne(number: Int) -> Int { return 1 + number } @@ -326,7 +326,7 @@ increment(7) 函数也可以当做参数传入另一个函数。 ```swift -func hasAnyMatches(list: [Int], condition: Int -> Bool) -> Bool { +func hasAnyMatches(list: [Int], condition: (Int) -> Bool) -> Bool { for item in list { if condition(item) { return true