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
protocol Vehicle { | |
var name: String { get } | |
associatedtype FuelType | |
func fillGasTank(with fuel: FuelType) | |
} | |
struct Car: Vehicle { |
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
```swift | |
import Combine | |
extension Publisher { | |
func fromResult<T, E>() -> AnyPublisher<T, E> | |
where Self.Failure == Never, Self.Output == Result<T, E>, E: Error { | |
setFailureType(to: E.self) | |
.tryMap { (result: Self.Output) -> T in | |
switch result { |
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
extension Publisher { | |
func unwrap() -> Publishers.CompactMap<Self, Self.Output> { | |
return compactMap({ $0 }) | |
} | |
func startWith1(_ value: Self.Output) -> Publishers.Merge<AnyPublisher<Self.Output, Self.Failure>, Self> { | |
return Publishers.Merge(Just(value).setFailureType(to: Self.Failure.self).eraseToAnyPublisher(), self) | |
} | |
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
// https://gist.github.com/MrAlek/3d1520ca2c5d981489e2 | |
import UIKit | |
enum Direction { | |
case left, right, up, down | |
var pointVector: CGPoint { | |
switch self { | |
case .left: return CGPoint(x: -1, y: 0) |
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
{ | |
address = { | |
addressText = "toru\U0144ski"; | |
apartment = "<null>"; | |
cityId = 1; | |
floor = "<null>"; | |
id = 0; | |
intercom = "<null>"; | |
latitude = "53.13196290250359"; | |
longitude = "18.30662839114666"; |