Add docstrings to Constructor.swift

This commit is contained in:
JP Simard 2018-04-29 17:00:56 -07:00
parent 2f3fe06fff
commit 42b94088a0
No known key found for this signature in database
GPG Key ID: 184C3F2916202C58
1 changed files with 16 additions and 0 deletions

View File

@ -432,10 +432,21 @@ extension Set {
// MARK: Sequence
extension Array {
/// Construct an Array of `Any` from the specified `sequence`.
///
/// - parameter sequence: Sequence to convert to `Array<Any>`.
///
/// - returns: Array of `Any`.
public static func construct_seq(from sequence: Node.Sequence) -> [Any] {
return sequence.map(sequence.tag.constructor.any)
}
/// Construct an "O-map" (array of `(Any, Any)` tuples) from the specified `sequence`.
///
/// - parameter sequence: Sequence to convert to `Array<(Any, Any)>`.
///
/// - returns: Array of `(Any, Any)` tuples.
public static func construct_omap(from sequence: Node.Sequence) -> [(Any, Any)] {
// Note: we do not check for duplicate keys.
return sequence.compactMap { subnode -> (Any, Any)? in
@ -445,6 +456,11 @@ extension Array {
}
}
/// Construct an array of `(Any, Any)` tuples from the specified `sequence`.
///
/// - parameter sequence: Sequence to convert to `Array<(Any, Any)>`.
///
/// - returns: Array of `(Any, Any)` tuples.
public static func construct_pairs(from sequence: Node.Sequence) -> [(Any, Any)] {
// Note: we do not check for duplicate keys.
return sequence.compactMap { subnode -> (Any, Any)? in