summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLevi Bostian <levi.bostian@gmail.com>2014-07-16 10:33:25 -0500
committerLevi Bostian <levi.bostian@gmail.com>2014-07-16 10:33:25 -0500
commit7568878a0d750413c0f6c077956a57d3e9ff4289 (patch)
tree506986122a841633acfd0c53a803e9c5381b6ab7
parent8904faca287102c38b1921ca7e4c67d53c910b88 (diff)
parentba855b16643661fef54842c5eb2d7ec93e29c4f9 (diff)
Merge pull request #677 from uraimo/patch-1
Update swift to beta3
-rw-r--r--swift.html.markdown11
1 files changed, 7 insertions, 4 deletions
diff --git a/swift.html.markdown b/swift.html.markdown
index f24b1592..a47b085a 100644
--- a/swift.html.markdown
+++ b/swift.html.markdown
@@ -31,7 +31,7 @@ optionalString = nil
// Array
var shoppingList = ["catfish", "water", "lemons"]
shoppingList[1] = "bottle of water"
-let emptyArray = String[]()
+let emptyArray = [String]()
// Dictionary
var occupations = [
@@ -65,7 +65,7 @@ for (key, value) in dict {
for i in -1...1 { // [-1, 0, 1]
println(i)
}
-// use .. to exclude the last number
+// use ..< to exclude the last number
// while loop
var i = 1
@@ -127,6 +127,7 @@ increment(7)
//
// Closures
//
+var numbers = [1, 2, 6]
// Functions are special case closures ({})
@@ -140,8 +141,10 @@ numbers.map({
})
// When the type is known, like above, we can do this
-var numbers = [1, 2, 6]
numbers = numbers.map({ number in 3 * number })
+//Or even this
+//numbers = numbers.map({ $0 * 3 })
+
print(numbers) // [3, 6, 18]
@@ -221,4 +224,4 @@ enum Suit {
// Generics: Similar to Java. Use the `where` keyword to specify the
// requirements of the generics.
-``` \ No newline at end of file
+```