This file contains 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
var cancellables = Set<AnyCancellable>() | |
func makeFutureWithDeferred() -> AnyPublisher<Int, Never> { | |
return Deferred { | |
return Future { promise in | |
print("Mason🍎🍎🍎: execute") | |
promise(.success(5)) | |
} | |
}.eraseToAnyPublisher() | |
} |
This file contains 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 makeFuture() -> Future<Int, Never> { | |
return Future { promise in | |
print("Mason🍎🍎🍎: execute") | |
promise(.success(5)) | |
} | |
} | |
let future = makeFuture() // Mason🍎🍎🍎: execute |
This file contains 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
import Combine | |
class MasonSubscriber: Subscriber { | |
typealias Input = String | |
typealias Failure = Never | |
var count = 0 | |
func receive(subscription: Subscription) { |
This file contains 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
import Foundation | |
protocol Container { | |
associatedtype Item | |
mutating func append(_ item: Item) | |
var count: Int { get } | |
subscript(i: Int) -> Item { get } | |
} |
This file contains 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 CountDown: Sequence { | |
var value: Int | |
struct CountDownIterator: IteratorProtocol { | |
var value: Int | |
mutating func next() -> Int ? { | |
if value < 0 { return nil } | |
defer{ value -= 1} // 여기서 사용되는 defer | |
return value | |
} |
This file contains 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
import Foundation | |
/// Ex.1 - 도로 표시 클래스 | |
/* | |
도로표시 | |
도로표시 + 차선 표시 | |
도로표시 + 교통량 표시 | |
도로표시 + 차선 표시 + 교통량 표시 | |
... |
This file contains 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
// | |
// MGesture.swift | |
// ViewPlayground | |
// | |
// Created by Youngsun Moon on 2020/03/21. | |
// Copyright © 2020 YoungSunMoon. All rights reserved. | |
// | |
import RxSwift | |
import RxCocoa |
This file contains 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 Car { | |
var brand: String = "KIA" | |
func getBrandObservable() -> Observable<String> { | |
return Observable.just(brand) | |
} | |
func getBrandDeferObservable() -> Observable<String> { | |
return Observable.deferred { [weak self] in | |
guard let self = self else { return .empty() } |
This file contains 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
import Foundation | |
/* | |
0. 문제있는 코드 | |
1. TicketSeller의 자율성 높이기 | |
2. Audience의 자율성 높이기 | |
3. Bag의 자율성 | |
4. TicketOffice의 자율성 | |
*/ |
This file contains 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 Array { | |
public subscript(safe index: Int) -> Element? { | |
return indices.contains(index) ? self[index] : nil | |
} | |
} | |
let gen: [[Int]] = [[1,1,0,0,0], | |
[1,1,0,0,0], |
NewerOlder