- Proposal: TBD
- Author: Erica Sadun, Brent Royal-Gordon
- Status: TBD
- Review manager: TBD
This proposal introduces a with function to the standard library. This function
| extension String { | |
| func split(separator:String) -> [String] { | |
| return self.componentsSeparatedByString(separator) | |
| } | |
| } | |
| extension Array { | |
| func unpack() -> (T)? { | |
| return count == 1 ? (self[0]) : nil | |
| } |
| public struct Distance :NumericType { | |
| public var value :Double | |
| public init(_ value: Double) { | |
| self.value = value | |
| } | |
| } | |
| extension Distance :IntegerLiteralConvertible { | |
| public init(integerLiteral: IntegerLiteralType) { | |
| self.init(Double(integerLiteral)) |
This proposal introduces a with function to the standard library. This function
This proposal enhances optional binding with a new, tuple-based syntax for
| // Evaluates the given closure when two `Optional` instances are not `nil`, | |
| // passing the unwrapped values as parameters. (Thanks, Mike Ash, Tim Vermeulen) | |
| // Following the example of IEEE754 with NAN, any comparison involving | |
| // .None is false | |
| // | |
| // See also: http://stackoverflow.com/questions/1565164/what-is-the-rationale-for-all-comparisons-returning-false-for-ieee754-nan-values | |
| /// Returns nil if either parameter is nil, or a tuple of the parameters | |
| /// otherwise. | |
| func all<T, U>(_ first: T?, _ second: U?) -> (T, U)? { |
| print(""" | |
| <?xml version="1.0"?> | |
| <catalog> | |
| \(bookTuples.map(xmlForBookTuple).joined(separator: "") | |
| )</catalog> | |
| """) | |
| typealias ChapterTuple = (heading: String) | |
| typealias BookTuple = (id: String, author: String, title: String, genre: String, price: String, chapters: [ChapterTuple]) | |