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
| func **<T: Multipleiable> (lhs: T, rhs: T) -> T { | |
| return lhs * rhs | |
| } |
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
| struct Point { | |
| let x: Int, y: Int | |
| var description: String { | |
| return "(\(x), \(y))" | |
| } | |
| } | |
| let p = Point(x: 21, y: 30) |
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
| struct Point { | |
| let x: Int, y: Int | |
| } | |
| let p = Point(x: 21, y: 30) | |
| print(p) | |
| // Prints "Point(x: 21, y: 30)" |
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
| struct Point: CustomStringConvertible { | |
| let x: Int, y: Int | |
| var description: String { | |
| return "(\(x), \(y))" | |
| } | |
| } | |
| let p = Point(x: 21, y: 30) | |
| let s = String(describing: p) |
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
| class Point: CustomStringConvertible { | |
| let x: Int, y: Int | |
| var description: String { | |
| return "(\(x), \(y))" | |
| } | |
| init(x: Int, y: Int) { | |
| self.x = x | |
| self.y = y |
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
| let string = "a b c d e f" | |
| let stringSplited = string.split(separator: " ") | |
| // stringSplited is String.SubSequence type |
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
| typealias MyInt = Int | |
| typealias YourInt = Int | |
| let age : MyInt = 10 // MyInt ๋ Int ์ ๋ค๋ฅธ ์ด๋ฆ์ ๋๋ค. | |
| let year : YourInt = 20 // YourInt ๋ Int ์ ๋ค๋ฅธ ์ด๋ฆ์ ๋๋ค. | |
| let sum : Int | |
| sum = year + age | |
| // result: 30 |
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
| let input = readLine() |
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
| let input = readLine() | |
| if let inputed = input { | |
| print(inputed) | |
| } else { | |
| print("Non inputed") | |
| } |
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
| struct MyPoint { | |
| private(set) var x = 0 | |
| private(set) var y = 0 | |
| init(x: Int = 0, y: Int = 0) { | |
| self.x = x | |
| self.y = y | |
| } | |
| } |