Last active
June 27, 2019 16:19
-
-
Save JoshuaSullivan/72cfabb9ac63aa2721d5 to your computer and use it in GitHub Desktop.
Revisions
-
JoshuaSullivan revised this gist
Dec 24, 2015 . No changes.There are no files selected for viewing
-
JoshuaSullivan created this gist
Dec 23, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ let baseString = "/Documents/" let words = ["Alpha", "Beta", "Gamma", "Delta"] var paths : [String] = [] for (var i = 0; i < words.count; ++i) { let word = words[i] paths.append("\(baseString)\(word)") } print(paths) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ for index, word in words.enumerate() { funcThatRequiresWordAndIndex(word, index: index) } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ let n = 4 print(--n) // Prints '3', value of n is now 3. print(++n) // Prints '4', value of n is now 4. print(n--) // Prints '4', value of n is now 3. Confusing! print(n++) // Prints '3', value of n is now 4. Also confusing! This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ for i in 0..<words.count { funcThatRequiresWordAndIndex(words[i], index: i) } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ let baseString = "/Documents/" let words = ["Alpha", "Beta", "Gamma", "Delta"] let paths = words.map({"\(baseString)\($0)"}) print(paths)