An open API service indexing awesome lists of open source software.

https://github.com/danramteke/zip2withnilpadding

Zip 2 implementation in Swift 4
https://github.com/danramteke/zip2withnilpadding

sequence swift swift4 zip

Last synced: 3 months ago
JSON representation

Zip 2 implementation in Swift 4

Awesome Lists containing this project

README

          

# Zip2WithNilPadding

An implementation of `Zip2` for different length Sequences, that fills the missing entries with `nil`.

Updated for Swift 4, based on a solution in this StackOverflow thread: https://stackoverflow.com/questions/25153477/in-swift-i-would-like-to-join-two-sequences-in-to-a-sequence-of-tuples

# Example

```
let first: [String] = ["a", "b", "c", "d"]
let second: [Int] = [1, 2]
let actual = Array(Zip2WithNilPadding(first, second))

# [(Optional("a"), Optional(1)), (Optional("b"), Optional(2)), (Optional("c"), Optional(3))]

```

# License

MIT License