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 characters
| // Functions in Swift | |
| func say(name: String) -> String { | |
| return name | |
| } | |
| say("Hello World") | |
| // Multiple parameters |
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 characters
| // for loop value range smaller then | |
| for i in 0..<10 { | |
| println(i) | |
| } | |
| println() | |
| // regular style for loop | |
| for var a = 0; a < 10; a++ { | |
| println(a) |
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 characters
| var first = 0 | |
| var second = 1 | |
| var result = 0 | |
| do { | |
| result = first + second | |
| first = second | |
| second = result | |
| println(result) | |
| } while result < 1000000000000 |
NewerOlder